tangix
19 Sep 2012, 1:31 AM
Maybe just a stupid mistake here, but I don't get why it doesn't work. I have a couple of stores in my small Sencha Architect project, configured as AjaxProxy with Reader, Writer and the fields configured inside of the Store. They all work - sync() sends changes to the server.
One Store is having 20+ fields so I thought I should break that out of the Store for tidyness and also to get a SequentialIdGenerator in place. Did that, set the Model of the Store and left the Reader/Writer on the Store. Adding records to the Store and doing sync() no longer works!
Moving the fields into the Store and all works well so the server and browser seems to be happy with the rest of the configuration.
For the moment I have moved the fields back into the Store and removed the SequentialIdGenerator (btw the Model approach did not work without this either) functionality and added that logic to the server, forcing me to reload the whole store from the server to get in sync... :-(
Ext.define('EL.model.QuestionModel', {
extend: 'Ext.data.Model',
alias: 'model.questionmodel',
fields: [
{
name: 'questiontext',
type: 'string'
},
{
name: 'questionid2',
type: 'int'
},
{
name: 'type',
type: 'int'
},
{
name: 'chkbox_count',
type: 'int'
},
{
name: 'value_unit',
type: 'string'
},
{
name: 'category',
type: 'string'
},
{
name: 'family',
type: 'string'
},
{
name: 'topic',
type: 'string'
},
{
name: 'ans1',
type: 'string'
},
{
name: 'ans2',
type: 'string'
},
{
name: 'ans3',
type: 'string'
},
{
name: 'ans4',
type: 'string'
},
{
name: 'ans5',
type: 'string'
},
{
name: 'ans6',
type: 'string'
},
{
name: 'ans7',
type: 'string'
},
{
name: 'ans8',
type: 'string'
},
{
name: 'corr_value1',
type: 'float'
},
{
name: 'corr_value2',
type: 'float'
},
{
name: 'corr_value3',
type: 'float'
},
{
name: 'corr_dev',
type: 'float'
},
{
name: 'corr_ans',
type: 'int'
},
{
name: 'questionorder',
type: 'int'
},
{
name: 'attachment',
type: 'string'
},
{
name: 'pic1',
type: 'string'
},
{
name: 'pic2',
type: 'string'
},
{
name: 'pic3',
type: 'string'
},
{
name: 'pic4',
type: 'string'
},
{
name: 'pic5',
type: 'string'
}
],
idgen: {
type: 'sequential',
id: 'questionid'
}
});
Ext.define('EL.store.QuestionStore', {
extend: 'Ext.data.Store',
alias: 'store.questionstore',
requires: [
'EL.model.QuestionModel'
],
constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
storeId: 'QuestionStore',
model: 'EL.model.QuestionModel',
proxy: {
type: 'ajax',
reader: {
type: 'json',
root: 'root'
},
writer: {
type: 'json',
allowSingle: false
}
}
}, cfg)]);
}
});
API setting code in launch (EL.config is set in a JS generated on the fly from the server - all other stores are configured in the same way):
Ext.getStore('QuestionStore').getProxy().url = EL.config.baseurl + 'question';
Ext.getStore('QuestionStore').getProxy().api = {
create : EL.config.baseurl + 'question/create',
read : EL.config.baseurl + 'question/read',
update : EL.config.baseurl + 'question/update',
destroy : EL.config.baseurl + 'question/destroy'
};
Any help greatly appreciated!
Thanks,
/Mattias
One Store is having 20+ fields so I thought I should break that out of the Store for tidyness and also to get a SequentialIdGenerator in place. Did that, set the Model of the Store and left the Reader/Writer on the Store. Adding records to the Store and doing sync() no longer works!
Moving the fields into the Store and all works well so the server and browser seems to be happy with the rest of the configuration.
For the moment I have moved the fields back into the Store and removed the SequentialIdGenerator (btw the Model approach did not work without this either) functionality and added that logic to the server, forcing me to reload the whole store from the server to get in sync... :-(
Ext.define('EL.model.QuestionModel', {
extend: 'Ext.data.Model',
alias: 'model.questionmodel',
fields: [
{
name: 'questiontext',
type: 'string'
},
{
name: 'questionid2',
type: 'int'
},
{
name: 'type',
type: 'int'
},
{
name: 'chkbox_count',
type: 'int'
},
{
name: 'value_unit',
type: 'string'
},
{
name: 'category',
type: 'string'
},
{
name: 'family',
type: 'string'
},
{
name: 'topic',
type: 'string'
},
{
name: 'ans1',
type: 'string'
},
{
name: 'ans2',
type: 'string'
},
{
name: 'ans3',
type: 'string'
},
{
name: 'ans4',
type: 'string'
},
{
name: 'ans5',
type: 'string'
},
{
name: 'ans6',
type: 'string'
},
{
name: 'ans7',
type: 'string'
},
{
name: 'ans8',
type: 'string'
},
{
name: 'corr_value1',
type: 'float'
},
{
name: 'corr_value2',
type: 'float'
},
{
name: 'corr_value3',
type: 'float'
},
{
name: 'corr_dev',
type: 'float'
},
{
name: 'corr_ans',
type: 'int'
},
{
name: 'questionorder',
type: 'int'
},
{
name: 'attachment',
type: 'string'
},
{
name: 'pic1',
type: 'string'
},
{
name: 'pic2',
type: 'string'
},
{
name: 'pic3',
type: 'string'
},
{
name: 'pic4',
type: 'string'
},
{
name: 'pic5',
type: 'string'
}
],
idgen: {
type: 'sequential',
id: 'questionid'
}
});
Ext.define('EL.store.QuestionStore', {
extend: 'Ext.data.Store',
alias: 'store.questionstore',
requires: [
'EL.model.QuestionModel'
],
constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
storeId: 'QuestionStore',
model: 'EL.model.QuestionModel',
proxy: {
type: 'ajax',
reader: {
type: 'json',
root: 'root'
},
writer: {
type: 'json',
allowSingle: false
}
}
}, cfg)]);
}
});
API setting code in launch (EL.config is set in a JS generated on the fly from the server - all other stores are configured in the same way):
Ext.getStore('QuestionStore').getProxy().url = EL.config.baseurl + 'question';
Ext.getStore('QuestionStore').getProxy().api = {
create : EL.config.baseurl + 'question/create',
read : EL.config.baseurl + 'question/read',
update : EL.config.baseurl + 'question/update',
destroy : EL.config.baseurl + 'question/destroy'
};
Any help greatly appreciated!
Thanks,
/Mattias