PDA

View Full Version : Store.sync nulls non visible fields



1099511627776
29 Dec 2011, 11:54 PM
Hellow world :)
I have this kind of problem.
I've defined a model:


Ext.define('ASV.model.docbody',{
extend: 'Ext.data.Model',
fields:[
{name: 'docrejid',type:'int'},
{name: 'docid',type:'int'},
{name: 'article',type:'string'},
{name: 'brand',type:'string'},
{name: 'name', type:'string'},
{name: 'quantity', type:'float'},
{name: 'price', type:'float'}
]
});

First 2 fields of this model are not supposed to be seen in a view. So I've defined view (gridPanel) columns like this:

columns:[
{header: 'article', dataIndex:'article',flex:1},
{header: 'brand', dataIndex:'brand', flex:1},
{header: 'name', dataIndex:'name', flex:2},
{
header: 'quantity',
dataIndex:'quantity',
flex:1,
field:{
xtype:'numberfield',
allowBlank:false,
minValue:0,
maxValue:10000
}

},
{
header: 'price',
dataIndex:'price',
flex:1,
field:{
xtype:'numberfield',
allowBlank:false,
minValue:0,
maxValue:10000
}
}
]

Now after editing and syncing data to server those to hidden fields became equal to 0.
Before Editing


{"body": [{"price": 119.0, "article": "24813", "brand": "FEBI BILSTEIN", "name": null, "quantity": 1.0}, {"price": 223.0, "article": "J1124031", "brand": "NIPPARTS", "name": null, "quantity": 1.0}, {"price": 153.0, "article": "5480XS", "brand": "GATES", "name": null, "quantity": 1.0}], "header": [{"docnumber": "ZK-1", "comment": null, "docid": 9, "summ": 495.0, "client": "\u041f\u0440\u043e\u0434\u0430\u043d \u041c.\u041c.", "date": "2011/12/26 11:14:55"}], "success": true}
After editing:

[{"docrejid":0,"docid":0,"article":"24813","brand":"FEBI BILSTEIN","name":"","quantity":1,"price":121},{"docrejid":0,"docid":0,"article":"J1124031","brand":"NIPPARTS","name":"","quantity":1,"price":223},{"docrejid":0,"docid":0,"article":"5480XS","brand":"GATES","name":"","quantity":1,"price":153}]

What am i doing wrong ?

1099511627776
30 Dec 2011, 12:25 AM
Just tried to define all columns in gridPanel with those 2 columns property hidden:true, but no effect

Farish
30 Dec 2011, 12:39 AM
The store can have as many fields as you like and the grid may show none or all the fields. this shouldn't affect the values of the other fields of that record. I don't see any problem here. Could you post the code of your store, how you sync it and also the complete grid code. Is this "before" and "after" related to editing or syncing? The first two fields are not there in one of them! This would mean if you try to save it, those two values would be missing and might be set to 0 on the server side and may be that is why you have 0 values.

Regards,
Farish

1099511627776
30 Dec 2011, 12:51 AM
Thanks for reply
it was my mistake
I've accidentally deleted those fields from initial response of the server
Now its all ok