PDA

View Full Version : Syncing propertyGrid does send modified record



1099511627776
2 Jan 2012, 8:03 AM
Hello.
Here is my problem:
I have a store (linked with propertyGrid with data:


[
{name:"name1",value:'value1'},
{name:"name2",value:'value2'},
{name:"name3",value:'value3'},
{name:"name4",value:'value4'},
]

- when I change for example property name2 and then sync the store, firebug shows that all the records are sent except the modified record
- when i change property name2 - sync acts the same way
- when I set the store property autoSync to true all works correctly. But I don't need autoSync I need manual sync

Is it a bug or I'm doin some think wrong

mitchellsimoens
2 Jan 2012, 9:47 AM
If you only changed one then it should only send one when you sync()

1099511627776
2 Jan 2012, 9:50 AM
Yes I know that but it does just the opposite, it sends ALL BUT CHANGED

1099511627776
2 Jan 2012, 9:56 AM
This is real example
server data:

{"header": [{"name": "docnumber", "value": "ZP-10"}, {"name": "comment", "value": "\u043a\u0443\u043a\u0443\u043a\u0443\u043a\u043a"}, {"name": "docid", "value": 59}, {"name": "summ", "value": 55732.0}, {"name": "client", "value": "ip-auto"}, {"name": "status", "value": "\u041e\u0442\u0440\u0438\u043c\u0430\u043d\u043e"}, {"name": "date", "value": "2011/12/31 22:01:29"}], "success": true}


changed data posted to server (changed comment field and as you can see there is no "comment" field):

[{"name":"client","value":"ip-auto"},{"name":"date","value":"2011/12/31 22:01:29"},{"name":"docid","value":59},{"name":"docnumber","value":"ZP-10"},{"name":"status","value":"\u041e\u0442\u0440\u0438\u043c\u0430\u043d\u043e"},{"name":"summ","value":55732}]

1099511627776
2 Jan 2012, 11:10 PM
I've made some investigations and here are the results:
1.When I change value of the "comment" field and that trigger sync method it invokes these commands:


toCreate = me.getNewRecords(), toUpdate = me.getUpdatedRecords(),

toDestroy = me.getRemovedRecords(),


toCreate - is filled with 6 values that was not modified
toUpdate - is filled with 0 (ZERO!!!) values
toDestroy - 0 values

May be some people here can explain why is it so? I think that when I change the value of one record it should be some thing like this:
- toCreate = 0
- toUpdate = 1
- toDestroy = 0

Am I wrong ?

1099511627776
2 Jan 2012, 11:46 PM
A small workaround:
When I edit record it propertyGrid, it sets model proerpty pantom to false.
that when invoking sync method it filters records and records with phantom == false are filtered out.
toUpdate - is empty and that is why the modified records are not sent to the server
a small workaround is to add listener to update event with such code:


store.on('update',
function(store,record,operation){
record.phantom = true;
});


this forcibly sets phantom property to record and it will be sent to server in toCreate packet

DiscoBoy
17 Feb 2012, 2:41 AM
I have a very similar problem with propertyGrid: I configure a store record (different store) as the grids source. The grid is nested in a window, so if I close this window (= neglecting changes to my record), I want my record to be unmodified - even I made changes in the grid.

Currently the grids update behavior is to set all modified values in my record (grid source), so the changes live on in my record after closing the grid (= unwanted behaviour). Therefore I would like to reject changes made to record on grid closing. Unfortunately the grid never marks values as modified after editing, thus calling record.reject() doesn't work! This might be a bug in ExtJS 4.07...do you have any other/better idea how I could reject changes to my record?