PDA

View Full Version : [solved]data store reload into extend



deka49
23 Feb 2009, 7:49 AM
hello,

if I call "detailStore" from "Ext.extend (editWindow, Ext.Window ,..." I get an error:" undefined detailStore, please use W3C .... "
how to load "detailStore" into extend please?


bonjour,

si j'appelle "detailStore" depuis "Ext.extend(editWindow, Ext.Window,..." j'obtiens une erreur : "detailStore undefined, please use W3C.... "
comment faire svp ?

rp.gridComDetail.js


var detailStore = new Ext.data.Store({
id: 'detailStore',
proxy: new Ext.data.HttpProxy({
url: 'php/dbCommande.php',
method: 'POST'
}),
baseParams:{task:"LISTDETAIL"},
reader: new Ext.data.JsonReader({
root: 'results',
totalProperty: 'total',
id: 'id',

},[
{name: 'num_li', type: 'int', mapping:'num_li'},
...
{name: 'tot_art_htva', type: 'float', mapping:'tot_art_htva'},

]),
sortInfo:{field: 'rech_id', direction: "ASC"}
})


rp.gridComDetail = Ext.extend(Ext.grid.EditorGridPanel,{

initComponent:function() {


var config = {
store: detailStore
,selModel: new Ext.grid.RowSelectionModel({singleSelect:true})
,enableHdMenu:false
,columns: [{
...
}]
,viewConfig:{forceFit:true}
,loadMask:true
}


Ext.apply(this, Ext.apply(this.initialConfig, config));
rp.gridComDetail.superclass.initComponent.apply(this, arguments)

}
,onRender:function() {

// // call parent
rp.gridComDetail.superclass.onRender.apply(this, arguments);

}

});
Ext.reg('gridComDetail', rp.gridComDetail);


editWindow.js


var editWindow = function(config) {
var myConfig = {};
...

this.detailGrid = new rp.gridComDetail({
id:'detailGrid',
title: 'detail',
scope : this,
//listener:

});
...

this.mainPanel = new Ext.FormPanel({
...

});

this.editPanel = new Ext.TabPanel({
id:'editPanel',
activeTab:0,
items:[this.mainPanel,this.detailGrid]

});

//Defaults
Ext.apply(myConfig, config, {
width : 810,
height : 350,
closable : false,
resiable : false,
closeAction : 'hide',
layout : 'fit',
modal : true,
items : [this.editPanel],

});

editWindow.superclass.constructor.call(this, myConfig);
};

Ext.extend(editWindow, Ext.Window, {
show : function (record) {
....

if (record) {
this.formDataObj = record;

detailStore.reload({params: {start: 0, limit: 30, bon_num: num}});
this.loadData (record);
}
else {
this.resetForm();
}
},
...
}

webby
23 Feb 2009, 8:00 AM
Try passing in the store on creation of your detailGrid.


this.detailGrid = new rp.gridComDetail({
id:'detailGrid',
title: 'detail',
scope : this,
store: detailStore

});

Or if it is not going to change then put the store code inside your extended component.

No expert but hope it helps.

jsakalos
23 Feb 2009, 8:01 AM
Is there any reason why you have detailStore outside of extended class? I usually do it like this: http://examples.extjs.eu/?ex=gridintab (see the source please)

deka49
23 Feb 2009, 10:01 AM
thanks for reply

rp.gridComDetail.js


rp.gridComDetail = Ext.extend(Ext.grid.EditorGridPanel,{

initComponent:function() {


var config = {

store: new Ext.data.Store({
id: 'detailStore',
proxy: new Ext.data.HttpProxy({
url: 'php/dbCommande.php',
method: 'POST'
}),
baseParams:{task:"LISTDETAIL"},
reader: new Ext.data.JsonReader({
root: 'results',
totalProperty: 'total',
id: 'id',

},[
{name: 'num_li', type: 'int', mapping:'num_li'},
...
{name: 'tot_art_htva', type: 'float', mapping:'tot_art_htva'},

]),
sortInfo:{field: 'rech_id', direction: "ASC"}
})
,selModel: new Ext.grid.RowSelectionModel({singleSelect:true})
,enableHdMenu:false
,columns: [{
...
}]
,viewConfig:{forceFit:true}
,loadMask:true
}


Ext.apply(this, Ext.apply(this.initialConfig, config));
rp.gridComDetail.superclass.initComponent.apply(this, arguments)

}
,onRender:function() {


rp.gridComDetail.superclass.onRender.apply(this, arguments);

}

});
Ext.reg('gridComDetail', rp.gridComDetail);


editWindow.js


var editWindow = function(config) {
var myConfig = {};
...


this.detailGrid = new rp.gridComDetail({
id:'detailGrid',
title: 'detail',
scope : this,
//listener:

});
...

Ext.extend(editWindow, Ext.Window, {
show : function (record) {
....

if (record) {
this.formDataObj = record;

this.detailGrid.store.reload({params: {start: 0, limit: 30, bon_num: num}});
this.loadData (record);
}
else {
this.resetForm();
}
},
...
}