PDA

View Full Version : defaultSortDirection config not present in store of EXT-JS 5



rakesh.mmp
5 Mar 2015, 4:33 AM
I have upgraded my project from Ext-js 4.2 to Ext-js5.
In Ext-js 5 there is no config such as defaultSortDirection present which was there in Ext-js 4.2 .
Can anyone help me out if there is some alternative present for this.
Thanks & Regards
Rakesh

yeghikyan
5 Mar 2015, 4:48 AM
in doc:


var store = Ext.create('Ext.data.Store', { model: 'User',
sorters: [{
property: 'age',
direction: 'DESC'
}, {
property: 'firstName',
direction: 'ASC'
}],


filters: [{
property: 'firstName',
value: /Ed/
}]
});

rakesh.mmp
5 Mar 2015, 5:14 AM
Hi ,
Thank You for the reply.

Actually in the project we will send parameters to service like



page : 1,
size : 10,
dir : 'ASC'


As you can see in the above code dir:'ASC' used to go to the service automatically when
defaultSortDirection set to ASC.Now this config is not present in Ext-js 5 store.

So i wanted to know solution for this.

Thanks & Regards
Rakesh

yeghikyan
5 Mar 2015, 5:29 AM
The format of sorters json is verbessert in 5-th version, for the following code:


Ext.define('SimpsonsModel', { extend: 'Ext.data.Model',
fields: [
'name',
'email',
'phone'
]
});


Ext.application({
name: 'Fiddle',


launch: function() {
var simpsonsStore = Ext.create('Ext.data.Store', {
storeId: 'simpsonsStore',
model: 'SimpsonsModel',
sorters: [{
property: 'name',
direction: 'DESC'
}, {
property: 'email',
direction: 'ASC'
}],
proxy: {
type: 'ajax',
url: '/users.json',
reader: {
type: 'json',
root: 'simpsons'
}
}
});


Ext.create('Ext.grid.Panel', {
title: 'Simpsons',
store: simpsonsStore,
columns: [{
text: 'Name',
dataIndex: 'name'
}, {
text: 'Email',
dataIndex: 'email',
flex: 1
}, {
text: 'Phone',
dataIndex: 'phone'
}],
height: 200,
width: 400,
dockedItems: [{
xtype: 'toolbar',
items: [{
text: "Load",
handler: function(btn) {
btn.up('grid').getStore().load();
}
}]
}],
renderTo: Ext.getBody()
});
}
});

It will send the following request to the server:




_dc:
1425562101444
page:
1
start:
0
limit:
25
sort:
[{"property":"name","direction":"DESC"},{"property":"email","direction":"ASC"}]

rakesh.mmp
5 Mar 2015, 5:55 AM
This is the code for store.
I have given Property in sorter, but it is not going in sort to service in request.



Ext.define('fullhouse.store.testStore', {
extend: 'Ext.data.Store',
alias: 'store.testStore',


requires: [
'fullhouse.model.testModel',
'Ext.data.proxy.Rest',
'Ext.data.reader.Json',
'Ext.data.writer.Json',
'Ext.util.Sorter'
],


constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
pageSize: 10,
storeId: 'testStore',
autoLoad: false,
model: 'application.model.testModel',
proxy: {
type: 'rest',
api: {
read: application.view.util.constant.serviceUrl+'test',
update: application.view.util.constant.serviceUrl+'test',
create: application.view.util.constant.serviceUrl+'test',
destroy: application.view.util.constant.serviceUrl+'test'
},
extraParams: {
searchText: '',
status: ''
},
limitParam: 'size',
simpleSortMode: true,
headers: {
Accept: 'application/json',
'Content-Type': 'application/json; charset=utf-8'
},
appendId: false,
reader: {
type: 'json',
rootProperty: 'data',
totalProperty: 'totalElements'
},
writer: {
type: 'json'
},

},
sorters: {
property: 'name',
direction: 'ASC'
},

}, cfg)]);
},





});

yeghikyan
5 Mar 2015, 6:35 AM
I have forgotten:

remoteSort: true
property in store.
Pardon :D

rakesh.mmp
5 Mar 2015, 10:06 PM
Thank you it is working now.