Reputation: 8176
I follow instruction in writer to create grid with CRUD ability, but the problem is when I edit existing row and save() it recognize that dirty row as create, I think the problem may lie in my idProperty as in link, but can't figure out how.
Here is my code
Column model
var xsmWin = new Ext.grid.CheckboxSelectionModel({checkOnly:true});
var xcmWin = new Ext.grid.ColumnModel([
xsmWin,
new Ext.grid.RowNumberer(),
{header: 'id', dataIndex: 'finCol0', align: 'left', hidden: true, hideable: false, sortable: false, width: 70},
{header: 'column name', dataIndex: 'finCol2', align: 'left', hidden: false, hideable: false, sortable: true, width: 100, editor: new samart.form.xTextField({allowBlank: false})},
{header: 'input type', dataIndex: 'finCol3', align: 'left', hidden: false, hideable: false, sortable: true, width: 100},
{header: 'approve', dataIndex: 'approveFlag', align: 'center', hidden: false, hideable: false, sortable: true, width: 50},
]);
Proxy
var proxyWin = new Ext.data.HttpProxy({
api : {
read : {
url : SERVLET_URL + '&action=loadInnerDataGrid',
method: 'POST'
},
create : {
url : SERVLET_URL + '&action=createInnerData',
method: 'POST'
},
update : {
url : SERVLET_URL + '&action=updateInnerData',
method: 'POST'
},
destroy : {
url : SERVLET_URL + '&action=destroyInnerData',
method: 'POST'
}
}
});
Reader and Writer
var writerWin = new Ext.data.JsonWriter({
encode: true,
writeAllFields: false
});
var readerWin = new Ext.data.JsonReader(
{
idProperty: 'finCol0',
root: 'data'
},[
{name: 'finCol0',mapping:'fundHeadSeq'},
//{name: 'finCol1',mapping:'fundType'},
{name: 'finCol2',mapping:'headLabel'},
{name: 'finCol3',mapping:'objectName'},
{name: 'approveFlag',convert: function(v, record){
if (record.approveFlag == 'Y') {
return 'Yes';
} else if (record.approveFlag == 'N') {
return 'No';
}
}},
]
)
Store
var xstoreWin = new Ext.ux.data.PagingStore({
storeId : 'xstoreWin',
proxy : proxyWin,
reader : readerWin,
writer : writerWin,
autoSave : false,
autoLoad : true
});
Upvotes: 2
Views: 2459
Reputation: 1
I have a problem similar to yours.
My IdProperty
was 'user_id'
and the writer create was never called. I changed to 'userId'
and it work now.
Very strange. I'm under Extjs 3.4
.
Upvotes: 0
Reputation: 8176
I have change
idProperty : 'finCol0' to idProperty : 'fundHeadSeq'
and
{name: 'finCol0',mapping:'fundHeadSeq'}, to {name: 'fundHeadSeq',mapping:'fundHeadSeq'},
in JSONWriter and change
{header: 'id', dataIndex: 'finCol0', align: 'left', hidden: true, hideable: false, sortable: false, width: 70},
to
{header: 'id', dataIndex: 'fundHeadSeq', align: 'left', hidden: true, hideable: false, sortable: false, width: 70},
in column model and everything work as expected.
Upvotes: 2