JeffHowden
03-01-2007, 03:47 AM
So, I know many of you extended the behavior of the 0.33 grid to send the name of the column that was sorted to the server. However, for those of you who need to use the Ext 1.0 version in the same way, here's how to do it (assuming ds is a variable that refers to your datastore and cm is a variable that refers to your column model):
ds.on('beforeload', function() {
ds.baseParams = {
sort: cm.getIndexById(ds.sortInfo.field)
};
});
Now, on the server, you'll see a form variable named "sort" that'll contain the index of the column that was sorted.
In my system, I actually take a look at the sort index to determine if it's supposed to be ASC (1) or DESC (-1). So, my sort value is determined like this:
ds.on('beforeload', function() {
ds.baseParams = {
sort: cm.getIndexById(ds.sortInfo.field) * ((ds.sortInfo.direction.toUpperCase() == 'DESC') ? -1 : 1)
};
});
So, if the 3rd column is sorted descending, I get -2 (remember, JS arrays start at 0) in the request to the server.
ds.on('beforeload', function() {
ds.baseParams = {
sort: cm.getIndexById(ds.sortInfo.field)
};
});
Now, on the server, you'll see a form variable named "sort" that'll contain the index of the column that was sorted.
In my system, I actually take a look at the sort index to determine if it's supposed to be ASC (1) or DESC (-1). So, my sort value is determined like this:
ds.on('beforeload', function() {
ds.baseParams = {
sort: cm.getIndexById(ds.sortInfo.field) * ((ds.sortInfo.direction.toUpperCase() == 'DESC') ? -1 : 1)
};
});
So, if the 3rd column is sorted descending, I get -2 (remember, JS arrays start at 0) in the request to the server.