PDA

View Full Version : GridPanel: sortInfo ASC



rolfext
29 Oct 2009, 6:38 AM
Hi,
i have a problem with the sortInfo in Gridpanel...

test case:
-use the example grid of "progress-bar-pager"
-duplicate the records ( i mean ['3m Co',71.72,0.02,0.03,'9/1 12:00am'] etc..) to get many pages


problem:
- the 1st order by (-> by code) and the one by the click on the dropdown menu in the "ASC case" does not work
- the DESC works fine by the dropdown menu only

what is my fault?:(

thanks

Animal
29 Oct 2009, 6:50 AM
It will sort the Store's cache (The current page), not the backing Array that the PagingMemoryProxy reads from. This is local sorting.

I assume you are just testing and won't be using anything as pointless as a PagingMemoryProxy in real life.

When you page, you page from a server, and you specify remote sorting which asks the server to sort, and it performs its query again with an "ORDER BY" clause and returns the data.

rolfext
29 Oct 2009, 7:08 AM
my SQL order the result the 1st time, but the grid does not show this order...

however I need to re-order the record showed without recall the sql...
The problem is present also with only 1 page loaded...

Thanks

rolfext
29 Oct 2009, 7:23 AM
ok, with "remoteSort:false" i can reorder the every page showed as i click.:)

could i re-order all the pages loaded from my sql at 1st without call it another time (not only the showed) ?

thanks

Animal
29 Oct 2009, 7:25 AM
Remote sorting means it queries the server again passing the column name and order. The server must return the sorted dataset.

Take a look in Firebug and you'll see how it works.

rolfext
29 Oct 2009, 7:36 AM
thanks, now it is clear. i tested it on server...
but i'm looking for something to avoid the re-call to the server for the total re-order... just like the change of page...:-/

Animal
29 Oct 2009, 7:52 AM
What do you mean?

If your resultset is 30,000 rows and you want to sort it, your server has to do that.

rolfext
29 Oct 2009, 8:18 AM
yes, the server can do it... but so i need another call to it...
If I move from page 1 to 2 and so go on, all the records are already present ( no call to server).
It should be beatiful if i could re-order all the line already loaded without a new call to server (something like a cache...)

Thanks a lot for you time.:)

Animal
29 Oct 2009, 8:20 AM
If you are using server paging, then the only way to get the next page is from the server.

If you are NOT using server paging, then you have all the data in the Store, and can use local sorting.

Just forget about this PagingMemoryProxy thing.

rolfext
2 Nov 2009, 7:48 AM
Hi , please take a look at my code and at my comment. I hope you can help me..:((

Thanks a lot!

============================
<script language="JavaScript"> Ext.onReady(function(){

var myData = [
['2','1020008_NAME','1020008_VORNAME','','1020008_STRASSE','','1955','1020008','0','','0','','','0','1','0','0','0']
,['2','1020013_NAME','','','1020013_STRASSE','','','1020013','0','','0','','','0','1','0','0','0']

......


];




<!-- I get from my sql many records . so i have many pages available in the grid -->
<!-- First time they are already ordered from server side -->
<!-- If I go to next page and so go on, the next records are showed without a new call to the server. I like this! -->
<!-- If I use the "dropdown order menu" I order only the records showed in the current page. -->
<!-- The question is: could I re-order all the records ( not only the showed ones in the current page, but all loaded by my sql from 1st page to last one) without a new call to server ? -->



// create the data store
var store = new Ext.data.Store({
proxy: new Ext.ux.data.PagingMemoryProxy(myData),
remoteSort:false,
reader: new Ext.data.ArrayReader({
fields: [
{name: 'IMG'}
,{name: 'NAME'}
,{name: 'VORNAME'}
,{name: 'ORT'}
,{name: 'STRASSE'}
,{name: 'ZUSATZ'}
,{name: 'GEBURTSDATUM'}
,{name: 'PFS_NR'}
,{name: 'PAR_ART_ID'}
,{name: 'SB_COUNTRY_ID'}
,{name: 'SB_ZIPCODE_ID'}
,{name: 'SB_KANTON_ID'}
,{name: 'PLZ'}
,{name: 'KUNDENSEGMENT_ID'}
,{name: 'NOT_IN_KO'}
,{name: 'PERSONAL_JN'}
,{name: 'ANREDE_ID'}
,{name: 'PAR_ID'}
]
})
});
var grid = new Ext.grid.GridPanel({
store: store,
columns: [
{
header: "" , width:24, renderer:renderIcon , sortable: true, dataIndex: 'IMG' ,visible:true}
,{id:'NAME',
header: "Name" , width:169 , sortable: true, dataIndex: 'NAME' ,visible:true}
,{
header: "Vorname" , width:149 , sortable: true, dataIndex: 'VORNAME' ,visible:true}
,{
header: "Ort" , width:144 , sortable: true, dataIndex: 'ORT' ,visible:true}
,{
header: "Strasse" , width:134 , sortable: true, dataIndex: 'STRASSE' ,visible:true}
,{
header: "Zusatz" , width:99 , sortable: true, dataIndex: 'ZUSATZ' ,visible:true}
,{
header: "Geburtsdatum" , width:79 , sortable: true, dataIndex: 'GEBURTSDATUM' ,visible:true}
,{
header: "" , width:0 , sortable: true, dataIndex: 'PFS_NR' ,visible:false, hideable: false}
,{
header: "" , width:0 , sortable: true, dataIndex: 'PAR_ART_ID' ,visible:false, hideable: false}
,{
header: "" , width:0 , sortable: true, dataIndex: 'SB_COUNTRY_ID' ,visible:false, hideable: false}
,{
header: "" , width:0 , sortable: true, dataIndex: 'SB_ZIPCODE_ID' ,visible:false, hideable: false}
,{
header: "" , width:0 , sortable: true, dataIndex: 'SB_KANTON_ID' ,visible:false, hideable: false}
,{
header: "" , width:0 , sortable: true, dataIndex: 'PLZ' ,visible:false, hideable: false}
,{
header: "" , width:0 , sortable: true, dataIndex: 'KUNDENSEGMENT_ID' ,visible:false, hideable: false}
,{
header: "" , width:0 , sortable: true, dataIndex: 'NOT_IN_KO' ,visible:false, hideable: false}
,{
header: "" , width:0 , sortable: true, dataIndex: 'PERSONAL_JN' ,visible:false, hideable: false}
,{
header: "" , width:0 , sortable: true, dataIndex: 'ANREDE_ID' ,visible:false, hideable: false}
,{
header: "" , width:0 , sortable: true, dataIndex: 'PAR_ID' ,visible:false, hideable: false}

],
stripeRows: true,
height:460,
width :820,
frame:true,
title:'',
plugins: new Ext.ux.PanelResizer({
minHeight: 100
}),
bbar: new Ext.PagingToolbar({
pageSize: 10,
store: store,
displayInfo: true,
plugins: new Ext.ux.ProgressBarPager()
}),
sm: new Ext.grid.RowSelectionModel({
singleSelect: true,
listeners: {
rowselect: {
fn: function(sm,index,record) {
chksubmitEXT(record.data,index);
}
}
}
})
});
function renderIcon(val) {
switch (val) {
case '0':
return '<img src="/images/private.gif">'
break;
case '1':
return '<img src="/images/no_private.gif">'
break;
case '2':
return '<img src="/images/pfs_import.gif">'
break;
default:
return'';
break;
}
}
grid.render("LNEWGRID");
store.load({params:{start:0, limit:10}});
});
</script>