My application
UITableView has 200 rows
In edit mode each cell has two actions for eg: passAction and failAction
After editing i want to update the database with either 0 or 1 based on its selection
I am retrieving data from server as json and storing it as object
Which is Best?
a. Requesting the server on each time the action is called.
b. Storing it in the local database and sync on completing all rows.
c. Request the server once on completion and send the whole object as JSON.
Help me in choosing the best option of implementation I can do!
Correct me if I bypassed any rules of SO because this is my first question!
#Dan Beaulieu: No need to send all data to server after edit. First update your database and Just send data which was changed in your database.
So add one field like "sync" in your database table and updated field set sync = 1 during edit and get data from database which was set sync = 1 and send it to server.
Related
I've been playing around with the example table-schematic for the Material Design [version: 11.0.3] table.
Basically i want to make a request, take the response and display it with the options to sort and limit the displayed items (pagination).
It works fine if I just replace the content of the connect function with "return a mapped Observable of the Response" but then the sorting and pagination obviously don't work anymore (since they are deleted) and i can't figure out how to make them work.
I assume the example pagination and sorting requires the data to be already present when the page loads/initializes (e.g. with a static Array).
Putting the request in the connect() function, saving the objects of the response to a variable and subscribing does work. However the page does not update after filling the initially empty array with data until sorting or pagination settings change. Which would make sense to me.
My question is, how do i get the data in there once and use the same data for pagination and sorting.
Can I even use the schematic in this case or is it misleading?
You can initialize a MatTableDataSource using an array of data, and then it will handle paging, filtering, and sorting locally and not try to fetch any more data.
See this example: https://stackblitz.com/angular/nleleddqmel?file=src%2Fapp%2Ftable-overview-example.ts
This example creates the data array locally, but you would instead use the response from your server request.
saving data from the component to database work great
dm.tabtier.FieldByName('clefamtiers').Asinteger:=dm.tabfamtiers.FieldByName('clefamtiers').AsInteger;
tabfamtiers is datasource of dxlookuptreeview
i need to show data from database to dxlookuptreeview but i can't make it go right ,
if condition found record then locate and show it
dxlookuptreeview1.text:=dm.tabfamtiers.FieldByName('famtiers').AsString
dxlookuptreeview1.rootvalue:=dm.tabtier.FieldByName('clefamtiers').Asinteger
but it did not work
I have a form using a Table of REQUEST Using IDRequest (int), TitleOfRequest
and other Table events which can have multiple events for the same request.
So the Table of events will include :
IDEVENTST,
IDRequest,
IDTypeofEvent,
DateStstrong textart,
DateEnd
Table of TYPEOfEvent : IdTypeOfEvent,TitleOfType
From my view to create a new record, the record will create at the final step, i want to make it in order
1 ) Enter a form with fields TitleOfRequest
And fields where the person can enter : DateStart and DateEnd, TypeOfEvent and a button to add, and load the temporary records in datatable.
My questions is : what is the best way to store this temporary data with MVC ? And refresh it in my view then at least to save in my database.
You could use [TempData] if you want to store data for the next request only.TempData allow us to persisting data for the duration of single subsequent request.
If data should be accessible between multiple requests, then use Session.
[Session] is able to store data much more long time, until user session is not expire.
Here is a good blogpost on this matter:
http://petermcintyre.com/2013/01/27/asp-net-mvc-data-persistence-choices/
What would be the best practise and best for user experience to achieve the following?
1:) Retrieve data from JSON
2:) Store in Core Data
3:) Display in UITableViewController
Do i store the JSON first, then populate the table using the stored data? OR Do i store it in the Core Data (background process) and populate the table using the JSON for the first time?
I want the user to be presented with a UITableview with minimum load time.
Thanks
This is what I would do:
Create your Core Data database and model.
Create a data access layer that will contain the read and write methods for each of your objects
In the read functions you can query the core data, if there is data then return that. Then in the background call the web server and and update your core data with the new JSON.
If there is no data go and request it from the web server, populate your core data tables using the JSON and then return the data from the core data so it is always consistent.
You can also have a last update date on your data so you are only requesting the new data from the web server that isnt already in your local core data DB. This will reduce the amount of data coming down to your ios device.
If you want minimum load time then I'd serve from JSON and that save to CoreData afterwards. That way the user can see content straight away without first having to wait for all the data to be saved (and parsed).
The course of action in this matter heavily depends on:
A. The amount of JSON data you are downloading
B. How effective your backend is at only sending necessary JSON results (rather than sending everything in bulk)
C. How you are attaching Core Data to your UITableViewController.
I recently made a pretty big project that does exactly this, which involved fetching a pretty big chunk of JSON, parsing it, and inserting it into Core Data. The only time there is any delay is during the initial load. This is how I accomplished it:
Download JSON. Cast as [[String: AnyObject]]: if let result = rawJSON as? [[String: AnyObject]] {}
Check to see if IDs for objects already exist in Core Data. If that object already exists, check if it needs update. If it doesn't exist, create it. Also check if IDs have been deleted from the JSON, if so remove them from.
Use NSFetchedResultsController to manage data from Core Data and populate the UITableView. I use NSFetchedResultsController rather than managedObjectContext.executeFetchRequest() because NSFetchedResultsController has delegate methods that are called every time the managedObjectContext is updated.
I need to get previous value of an entity.
My requirement is like; I have some input fields in an edit page.
1 User can enter some values there and press save button at this time the user should be able to save it.
2 User can enter some values there and press Cancel button at this time the page should be reloaded with whatever values were there before the user start editing the page.
My question is that can entity frame work, help us in getting previous value of an object?
Is self tracking is something related to this?
You mentioned "page" so I guess you are talking about web application. In such case you should simply load entity from the database again because pushing Cancel button will make a new request to your web application. You should use a new context per request so you don't have any previous data or entity to reload - you will run a new query and get last data persisted to database.
What you would want to do is:
myContext.Refresh(RefreshMode.StoreWins, myObject);
This will ask the context to reload the entity removing any changes to the object and replacing the property values from the data store.