View Full Version : groupField property in reconfigure method

19 Dec 2012, 2:26 AM

I have a reconfigure method like,

listeners: {
'metachange': function(store, meta) {
me.reconfigure(store, meta.columns);

I need to add groupField property to it while reconfiguring this grid. How should I do it?

Thanks in advance!

19 Dec 2012, 8:26 AM
Have your tried to set the groupField Property of the store, before you call reconfigure?

19 Dec 2012, 9:26 AM
This grid (http://www.sencha.com/forum/showthread.php?242594-Dynamic-grid-with-dynamic-model) isn't considering groupField property when I give it dynamically, meaning, I am sending grouping field to the grid by selecting from a combobox. When there is a groupField value initially in the store before loading the grid like,

groupField: 'group_this_field'

it does it well. Instead I am doing,

groupField: MyApp.Controller.param1

param1 have the value (from a combobox) for grouping.

So it is just reconfiguring the grid after initial load(?) :-/.

20 Dec 2012, 3:12 AM
Any input?

20 Dec 2012, 3:24 AM
well I dont think that if the groupField (MyApp.Controller.param1) is changed it will change the groupField in the Store as well, because that value is applied on the store on creation.

You have to apply the new value on the stores object again.

20 Dec 2012, 3:29 AM
How should I do that? Can you please give me some code that I can use there to make this work? :).

20 Dec 2012, 3:44 AM
by calling


20 Dec 2012, 3:56 AM
Thanks very much, this worked when I added in listener =D>.

Is there something to set totalProperty like,

instead of group?


20 Dec 2012, 4:42 AM
totalProperty is set on the reader. Be aware, it seems that if a totalProperty is returned in the metadata, the totalproperty is overwritten by the metadata.

20 Dec 2012, 4:50 AM
Can you please suggest some ideas to set totalProperty in this grid (http://www.sencha.com/forum/showthread.php?242594-Dynamic-grid-with-dynamic-model).

I have to set totalProperty in combination with metadata.

20 Dec 2012, 4:54 AM
If you see the docs http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.reader.Reader

property metadata, it says that the totalProperty is applied to reader when metadata is received.

20 Dec 2012, 5:12 AM
If you see the code,


* Lukas Sliwinski
* sliwinski.lukas@gmail.com
* Dynamic grid, allow to display data setting only URL.
* Columns and model will be created dynamically.

Ext.define('Ext.ux.grid.DynamicGrid', {
extend: 'Ext.grid.Panel',
alias: 'widget.dynamicGrid',
alternateClassName: 'Ext.grid.DynamicGrid',

requires: [
// URL used for request to the server. Required
url: '',

initComponent: function() {
console.log('DynamicGrid initComponent!');
var me = this;
if (me.url == '') {
Ext.Error.raise('url parameter is empty! You have to set proper url to get data form server.');
else {
var DynamicGrid = Ext.applyIf(me, {
columns: [],
forceFit: false,
store: Ext.create('Ext.data.Store', {
// Fields have to be set as empty array. Without this Ext will not create dynamic model.
fields: [],
// After loading data grid have to reconfigure columns with dynamic created columns
// in Ext.ux.data.reader.DynamicReader
listeners: {
'metachange': function(store, meta) {
me.reconfigure(store, meta.columns, meta.totalProperty);
autoLoad: true,
pageSize: 10,
remoteSort: false,
remoteFilter: false,
remoteGroup: false,
proxy: {
reader: {
type: 'dynamicReader',
totalProperty: 'totalCount'
type: 'rest',
url: me.url

me.bbar = Ext.create('Ext.PagingToolbar', {
store: me.store,
displayInfo: true,
displayMsg: 'Displaying topics {0} - {1} of {2}',
emptyMsg: "No topics to display"

Dynamic reader:

* @class Ext.ux.data.DynamicReader
* @extends Ext.data.reader.Json
* <p>Dynamic reader, allow to get working grid with auto generated columns and without setting a model in store</p>

* floatOrString data type provide proper sorting in grid for string and float
* if you don't now what data type of that two whould be in column
Ext.apply(Ext.data.Types, {
convert: function(v, n) {
v = Ext.isNumeric(v) ? Number(v) : v;
return v;
sortType: function(v) {
v = Ext.isNumeric(v) ? Number(v) : v;
return v;
type: 'floatOrString'

Ext.define('Ext.ux.data.reader.DynamicReader', {
extend: 'Ext.data.reader.Json',
alias: 'reader.dynamicReader',
alternateClassName: 'Ext.data.reader.DynamicReader',

readRecords: function(data) {
if (data.length > 0) {
var item = data[0];
//console.log("read records method called...");
var fields = new Array();
var columns = new Array();
var p;

for (p in item) {
if (p && p != undefined) {
// floatOrString type is only an option
// You can make your own data type for more complex situations
// or set it just to 'string'
fields.push({name: p, type: 'floatOrString'});
columns.push({text: p, dataIndex: p});

data.metaData = { fields: fields, columns: columns };
return this.callParent([data]);

I tried many ways to add totalProperty in dynamic reader also, nothing seems to work for pagingtoolbar. Am I doing it right?

21 Dec 2012, 1:07 AM
Any input? :).