I have a TADOQuery connected to a database, and sql set to fetch data.
TDataSetProvider to the above query
TClientDataSet connected to the provider
TDataSource connected to the Data set
Data source connected to a TcxGrid
The Client Data Set is also connected to a master source, that in itself is connected to a table.
I am able to add and delete to grid as expected (grid cannot be edited directly, all people can do is add or delete). I am using delete and append on the data set to control the grid.
What is strange and I cannot solve is that when I change what record is being used in the master source grid, and then go back to the original record the data is being refreshed from the database or some stored original state of data set, rather than the in-memory data set.
So if I had deleted a record, it reappears, and any still existing ones are duplicated, though anything added from last save to database is not duplicated. However if I do an update on the data set to the database, the database table is how I would expect. No duplicate records, anything deleted via grid/data set is deleted, anything added is added.
I suspect this is a really trivial flag setting, but I cannot find this, and every query others have seems to be about refreshing the data, not preventing it.
Any suggestions would be appreciated.
Related
I am new to Dynamics FnO, and recently followed the articles to access data through oData, and was successful.
What I see missing in the data objects that I normally receive in integrations out of the Microsoft World is the created/updated timestamps.
I am trying to put a synchronous data flow from FnO to my NodeJs application, so that my app keeps polling data from FnO whenever there is a change. This can be achieved easily if there were timestamps with the data that flows in.
Is there a way to setup those timestamps somewhere?
You have to make sure that the underlying table that you are querying has the fields added on it, and also that the data entity you are accessing through odata has the fields setup up on it as well.
Make sure this is setup on the table:
And then you have to drag and drop the field(s) from the datasource field list to the exposed field list in the data entity:
After this, you will have these fields
I'm trying to create a planning app with Swift 2, which pulls the data from a remote server via an API. The data of the API is ordered by time. The app shows the data in the exact same order as the API returns.
Now, however, I have created a UITableView which can be pulled to refresh the data. I also have added the possibility to rearrange the data to the likings of the user. When the user refreshes the table however, the data will all be restored to the order of the returned API data.
My question is: how can I still refresh the data, but let the data keep the current position in the table?
You control the order in which data is displayed by how you implement cellForRowAtIndexPath. The API doesn't control your UI.
If you choose to display the data in the order returned by the API, then yes, user will lose their custom arrangement when the table is reloaded.
If you want the user to control the order data is displayed, you will need to persist some information about the order so that you can keep that order when the table is reloaded.
In the simplest case, you could provide some default sort options that make sense for the kind of data you have. You might have a type or category value that makes sense to sort on. You would then only need to persist the sort options the user has chosen and sort your data when reloading the table.
If you want the user to have complete control over the order, then you need to persist that order and reapply it when the table is reloaded. This is considerably more challenging. Some options, from easiest to hardest:
1. You could persist the order locally using just an identifier that uniquely identifies each item.
2. You could persist all the data and the order locally.
3. You could persist the order on the server.
I have a REST service running on top of my application, which returns data to my iPad app. This app is built using RestKit to sync data in and out of the iPad. I have however a webapp running as well, which allows the users to delete some data.
The current problem that I have right now, is that whenever a user logs in into the iPad app, I run a query to get the data that was last_modified/added since his last login. This allows me to have faster/shorter queries. The only problem, is that if for example an object was deleted from the DB between his last two logins, the user will still see it in his iPad.
What strategy should I adopt to have this data in Core Data deleted as well? Should I just not delete object from my DB and have instead a BOOL that says "deleted" or not, and whenever I get the last_modified data via REST, this item will appear and I will just filter it out in the iPad?
I know RestKit has a way to delete orphans objects, but since I am syncing the "last_modified" data, I don't think it can be applied here.
From your comment question:
I created a list of objects that needs to be deleted from CoreData. So for I example, I return an array of IDS that corresponds to the Users I need to delete in CoreData. How can I do such mapping with RestKit?!
You should create a mapping to NSMutableArray. If your source data is a JSON array of strings then you will need to use a nil key path mapping in order to get the strings extracted into your destination array. See this link.
As Wain suggested, I will have a list of deleted objects in the Database with a "deleted_date" field. Whenever I will fetch the latest objects, I will also fetch the latest deleted objects back.
My app talk to webServer. At login, I pull down JSON and make up CoreData with 4 Entities (about 1000 rows each). The data changes on Server, So with every login, I have to update my existing CoreData.
What is the best approach to find out if records exist and insert new ones if need be?
To be smart on update (not blindly update every time), you need some intelligence on the server side.
One idea I would do.
Server has master table that records the timestamp of modified date of the 4 entities. It also has API to expose the master table. Every time change occurs to one of the 4 entities, master table's corresponding entry has to be updated as well.
You create the same copy of master table in application side as well.
On application launch, you query API in 1. and compare with the value in 2. to see if the timestamp has updated on the server side.
If YES, then download and replace the corresponding entity.
Another one which allows finer control.
Add timestamp column to the 4 entities on the server side. Every time entry is added/updated, the timestamp is updated.
Prepare an API for each entity that filters only newer items than the specified timestamp
On application launch, you query API in 2. and update.
The hole of the second approach is that it cannot handle deletion on the server side. Maybe you can combine something like the first approach to support this.
I am using TADOConn and TADODataSet units pulling data and connected to TDataSources and TDBGrids. I have my DBGrids displaying information properly and editing information in the detail view accurately reflects in the backing database.
What I would like to do is have it so that an update to a field in the detail DBGrid causes a refresh on both data sets so that the most up-to-date data is always displayed.
I have tried putting the refresh calls in several event handlers at various levels of DB access but they all seem to have a similar (but different) issue of reentry.
The best I've been able to come up with so far is getting the Master view updated by calling refresh on the details DBGrid.onColExit event.
If I leave the refresh calls out all together the updated information isn't displayed until the next time the application is run.
Any ideas of how to achieve this? Am I going about it the wrong why? Thanks in advance.
You imply that the changes you make in the DBGrid are posted to the database but are not displayed in the grid or maintained in its dataset and that you must get them back from the database. All the dataset components I have used maintain its copy of the data including all the changes that passed through it to the database. If you expect the data to be changed by triggers or another process, you may need to refresh the data. Then you will have to deal with the possibility that the current record position is lost, i.e. the current record was deleted in the database.
I would try using the Dataset.AfterPost event to initiate the refresh. And I would consider using a Timer to delay the refresh if strange things happen.