PDA

View Full Version : Session - updating records



Carun
17 Apr 2014, 1:01 PM
The documentation talks about an update method on the Session at various places, but there is no such method in Ext.data.session.Session. So how does one update a record that is in the session?

Once I get the changes from the Session using getChanges() and make an AJAX call to persist them, what is the mechanism to update the session?

A way to prevent the previous changes from showing up when session.getChanges() is called again.

sriram139
29 Apr 2014, 11:44 AM
+1.
Same issue here.. Any clues??

dongryphon
1 May 2014, 1:05 AM
The Session update method did not make the beta date so apologies for the confusion there. In the beta only the getSaveBatch (http://docs-devel.sencha.com/extjs/5.0.0/apidocs/#!/api/Ext.data.Session-method-getSaveBatch) mechanism has the necessary logic to call commit on the various records.

Carun
2 May 2014, 8:07 AM
Thanks Don! I have one follow up question.

Will there be a rejectChanges API on the session (like in Store) to clear the session of the changes?

To give you an example, consider a grid with pagination (data is fetched from the server). When the User edits across pages and wants to cancel his/her change, calling store.rejectChanges() will only revert the changes for the records in the store (mostly current page + anything trailing if configured) and there is a good chance of other modified records that are no longer available in the context of the store, but are in the session.

So having an API to clear out the session, will be of much use.

Hacker-CB
18 Aug 2014, 9:12 AM
I'm doing:
1. session.getChanges()
2. Send via ajax:

User: {
'U': [
{
id: 55,
name: 'Robert'
}
]
}

3. Ajax return:

User: {
'U': [
{
success: true,
data: {
id: 55,
name: 'Robert',
lastmodified: '2014-08-15 00:12:00'
}
}
]
}

So, how to pass returned from AJAX data to commit to current session ()In this example 'lastmodified' field should be changed in model?

Carun
17 Sep 2014, 5:29 PM
The update method wasn't doing what I expected, so I manually update the session contents with the response. I also have a reject changes method that gets the changes from the sessions and call a reject() on the records to invalidate the changes.Hope this helps.If anyone has done this differently, I am eager to hear about it.

Hacker-CB
17 Sep 2014, 10:39 PM
I have change backend to return JSON acceptable for update() method:

User: {
'U': [
{
id: 55,
name: 'Robert'
}
]
}