PDA

View Full Version : Multiple sorting in Extjs 4.1.1



techwiz
2 Mar 2016, 4:13 AM
Is multiple sorting available in Extjs version 4.1.1?

I am trying to implement multiple sorting feature in a simple panel grid with a json store.
Here is the link of the script:
http://docs.sencha.com/extjs/4.1.1/#!/example/grid/multiple-sorting.html
But the script which I got from the sencha docs is not working.

I want my grid with sorting to look something like this :
54092
Please help.

Thanks,
Deepika.

Gary Schlosberg
2 Mar 2016, 4:52 AM
As the example shows, it is available in 4.1.1. I've not tried with a JsonStore. What does your store config look like? What does your JSON data look like?

techwiz
2 Mar 2016, 11:04 PM
I have defined my jsonStore like this:

var createStore = function(columns, data) {
store = Ext.create('Ext.data.JsonStore',{
storeId: 'fsStore',
autoLoad: false,
root : 'data',
proxy: {
type: 'pagingmemory',
reader: {
type: 'json'
}
},
fields: columns,
data: data,
sorters: ['empCode','empId'],
groupField: 'empCode
listeners: {
'load' : function(store,records,options) {
if(records.length === 0) {
store.removeAll();
}
msg = updateProgressBarMsg(store, progressBarMsg);
Ext.getCmp('progressMsg').update(newMsg);
}
}
});
};

And the json data I got is like this:


columns:

[Object { id="empCode", header="Emp Code", dataIndex="empCode"}, Object { id="empId", header="Emp Id", dataIndex="empId"}]








data:

[Object { empCode=113, empId="57A"}, Object { empCode=113, empId="53S"}, Object { empCode=114, empId="46S"}, 40 more...]

Gary Schlosberg
7 Mar 2016, 3:27 PM
That doesn't look like valid JSON, which could be the issue. You can test your JSON for validity on sites such as this:
http://jsonlint.com/

techwiz
23 Mar 2016, 2:15 AM
Corrected my JSON response in jsonlint and it looks like this:
{
"columnData": [{
"id": "empCode",
"header": "Emp Code",
"dataIndex": "empCode",
"autoWidth": true,
"sortable": true,
"hidden": false
}, {
"id": "empId",
"header": "Emp Id",
"dataIndex": "empId",
"autoWidth": true,
"sortable": true,
"hidden": false
}]
}

And the sample data looks like:
[{
"empCode": 113,
"empId": "57A"
}, {
"empCode": 114,
"empId": "46S"
}]

This data works fine in my application but it is not working for advanced sorting for this type of JSON store and data.

Gary Schlosberg
24 Mar 2016, 1:30 PM
Can you describe what is not working about the sorting? Any chance you can recreate the issue in a test case?
https://fiddle.sencha.com/#home