PDA

View Full Version : viewConfig



chandan.behura
13 Sep 2012, 8:25 AM
What is the use of viewConfig for a grig.

If i will use a listeners inside a viewConfig them how i will be able to shift the listener part code to a controller in MVC Str.

mitchellsimoens
17 Sep 2012, 9:09 AM
The viewConfig allows you to configure the Ext.grid.View instance which is a component so the Controller will be able to listen for events.

chandan.behura
18 Sep 2012, 8:03 AM
The viewConfig allows you to configure the Ext.grid.View instance which is a component so the Controller will be able to listen for events.
I have done it for a


viewConfig : {
stripeRows : true,
listeners : {
beforerefresh : function(view) {

var store = view.getStore();
var model = view.getSelectionModel();
var s = [];
store.queryBy(function(record) {
if (record.get('shipToCountryValue') === 'GU : Guam') {
s.push(record);
}
});
model.select(s);
},
}
}


but how to take the listener part code to my controller In MVC str.
Can't i do my beforerefresh event without viweConfig.

mitchellsimoens
18 Sep 2012, 10:14 AM
You can use the xtype just like you would for the grid panel

chandan.behura
20 Sep 2012, 8:34 AM
You can use the xtype just like you would for the grid panel


You mean,
in grid:


viewConfig : { stripeRows : true,

action:'ref' }




in side conrtoller:



init : function() {

this.control({
' viewConfig[action=ref]' : { //will it be viewConfig
beforerefresh : this.onBeforeRefresh
},
});


onBeforeRefresh : function(view) { var store = view.getStore(); var model = view.getSelectionModel(); var s = []; store.queryBy(function(record) { if (record.get('shipToCountryValue') === 'GU : Guam') { s.push(record); } }); model.select(s); }, }


I am not tried that one but could u plz verify where it will create a problem.

mitchellsimoens
20 Sep 2012, 5:40 PM
The viewConfig will be used to create the Ext.grid.View component which has an xtype of gridview so instead of viewConfig in your controller, use gridview