PDA

View Full Version : composite key and JsonWriter with writeAllFields: false



ilyas
10 Oct 2010, 4:32 AM
I have DB table with composite key (id_1, id_2). I want to work with it by EditorGridPanel:


mygrid = new Ext.grid.EditorGridPanel({
...
store: new Ext.data.JsonStore({
proxy: new Ext.data.HttpProxy({
api: { ... }
}),

writer: new Ext.data.JsonWriter({
encode: true,
writeAllFields: false
}),

idProperty: 'id_1',

fields: [{
name: 'title',
type: 'string'
}]
})
})
before using this grid, I do this:


mygrid.getStore().setBaseParam('id_2', 'some id');
reading data from server is work fine (id_2 is sent)
but when I try to update an record, id_2 is not sended.. What is wrong?

Condor
11 Oct 2010, 1:56 AM
Store, DataReader and DataWriter all need unique ids (and idProperty:'id_1' just isn't unique).

Could you concatenate id_1 and id_2 into a single "id" field?

ilyas
12 Oct 2010, 4:24 AM
In fact, I have two grid in the panel. In the first grid I choose the main entry and the second is used to implement many-to-many relationships in my database (with another table). Uniqueness of id_1 is guaranteed by my server code.

The general question is: what I need to do, so that when any requests (read or update) are sent id_2?

Condor
12 Oct 2010, 4:40 AM
That is strange. JsonWriter should add the baseParams to the update request.

Which Ext version are you using?

ilyas
12 Oct 2010, 5:32 AM
3.2.1

Condor
12 Oct 2010, 5:35 AM
Strange... I clearly see the baseParams being added to the request (line 23316/23320 of ext-all-debug.js).