samedi 20 septembre 2014

Store disappear after sencha app build.

I have an application with grid and paging , when I run my web app I create a store and then assign it to the grid on the view define and everything works fine (grid works with paging).

After I run sencha app build , The grid and the paging don't have the store binded and I have to manually re bind them in the code.



Code:



var polySearchStore = Ext.create('GIS.store.Polygons', {
storeId: 'polygonStore',
pageSize: itemsPerPage
});

Here I define the grid :

Code:



Ext.define('GIS.view.PolygonGrid', {
extend: 'Ext.grid.Panel',
alias: 'widget.userlist',
id: 'gridList',
store: polySearchStore, // same store GridPanel is using
columns: [
{
dataIndex: 'clock',
flex: 1,
editor: 'textfield'
},
{
dataIndex: 'name',
flex: 1
}
],
listeners: {
itemclick: function (grid, record, item, index, e) {
searchLayer.removeAllFeatures();
res = grid.getSelectionModel().getSelection();
wkt = new OpenLayers.Format.WKT();
feature = new OpenLayers.Feature.Vector(OpenLayers.Geometry.fromWKT(res[0].get('geom')).transform(epsg4326, epsg900913));
feature = feature.clone();
searchLayer.addFeatures([feature]);
map.zoomToExtent(searchLayer.getDataExtent());
Ext.getCmp("frmSearchPolygon").close();
}
},
dockedItems: [{
xtype: 'pagingtoolbar',
id: 'polygonGridPaging',
store: polySearchStore, // same store GridPanel is using
dock: 'bottom',
displayInfo: true
}],
initComponent: function () {
this.callParent(arguments);
}
});

Here I define the search form with the grid result on bottom:

Code:



Ext.define('GIS.view.PolygonSearch', {
title: tr("Search Polygon"),
extend: 'Ext.window.Window',
id: 'frmSearchPolygon',
width: 500,
closable: true,
resizable: false,
draggable: true,
items: [
{
xtype: "form",
border: false,
bodyPadding: 5,
buttonAlign: "center",
items: [
{
xtype: "radiogroup",
id: "radiogroup",
fieldLabel: tr("Choose"),
columns: 1,
vertical: true,
items: [
{
xtype: "container",
layout: "hbox",
items: [
{
xtype: "radio",
boxLabel: tr("Clock"),
checked: true,
width: 90,
name: "rb",
id: "rb1",
inputValue: "1"
},
{ xtype: "splitter" },
{
xtype: "textfield",
name: "rbtnClock",
listeners: {
focus: {
fn: function (that, e, eOpts) {
Ext.getCmp('rb1').setValue(true);
},
scope: this
}
}

}]
},
{
xtype: "container",
layout: "hbox",
hidden: false,
items: [{}]
},
{
xtype: "container",
layout: "hbox",
items: [{
xtype: "radio",
boxLabel: tr("Name"),
width: 90,
name: "rb",
id: "rb2",
inputValue: "2"
}, {
xtype: "splitter"
}, {
xtype: "textfield",
name: "rbtnName",
listeners: {
focus: {
fn: function (that, e, eOpts) {
Ext.getCmp('rb2').setValue(true);
},
scope: this
}
}
}]
}
]
}

],
buttons: [{
text: tr("Search"),
formBind: true,
disabled: true,
handler: function (b, e) {
var form = this.up('form').getForm();
if (form.isValid()) {

clock = "";
name = "";
if (form.getValues().rb == 1) {
clock = form.getValues().rbtnClock;
}
else {
name = form.getValues().rbtnName;
}

store = Ext.getCmp('gridList').getStore();
store.load({ params: { code: params.code, clock: clock, name: name, limit: itemsPerPage} });
//polySearchStore.load({ params: { code: params.code, clock: clock, name: name, limit: itemsPerPage} });
}
}
}]
}
,
{
xtype: 'userlist'
}
]
})

And this is how I rebind the store :

Code:



wSearchPolygon = Ext.create("GIS.view.PolygonSearch");
Ext.getCmp('gridList').bindStore(polySearchStore);
Ext.getCmp('polygonGridPaging').bindStore(polySearchStore);

So... Why after sencha app build I need to rebind while before the build the code works fine ?



Store disappear after sencha app build.

Aucun commentaire:

Enregistrer un commentaire