Forum
05:41
16/04/2009
The sortGrid function in grid.custom.js takes a colname and if this column is sortable calls sortData as follows:
$t.sortData(colname, idx, reload);
However sortData requires an index (in the form jqgh_ + colname) to be able to re-apply the sort image and correctly set the sortname.
Here is a snippet form the sortData code that relies on the index having 'jqgh_' as a prefix to the colname.
$("tr th div#jqgh_"+ls+" img",thd).remove();
$("tr th div#jqgh_"+ls,thd).parent().removeClass(ts.p.sortclass);
iId = index.replace('.',"\\\\.");
$("tr th div#"+iId,thd).append(imgs).parent().addClass(ts.p.sortclass);
ts.p.lastsort = idxcol;
index = index.substring(5);
ts.p.sortname = ts.p.colModel[idxcol].index || index;
so = ts.p.sortorder;
if(onSortCol) {onSortCol(index,idxcol,so);}
You can see that the image is removed along with the class using an id of jqgh_ + a column name. However if the index passed into sortData does not have jqgh_ as a prefix (as it does when called from other parts of grid.base.js) the sorting does not work.
My fix to this has been to alter sortGrid function in grid.custom.js to the following:
sortGrid : function(colname,reload){
return this.each(function(){
var $t=this,idx=-1;
if ( !$t.grid ) { return;}
if ( !colname ) { colname = $t.p.sortname; }
for ( var i=0;i<$t.p.colModel.length;i++ ) {
if ( $t.p.colModel[i].index == colname || $t.p.colModel[i].name==colname ) {
idx = i;
break;
}
}
if ( idx!=-1 ){
var sort = $t.p.colModel[idx].sortable;
if ( typeof sort !== 'boolean' ) { sort = true; }
if ( typeof reload !=='boolean' ) { reload = false; }
/* David Gallop 5/3/2009
* The colname expected by the sortData function
* in grid_base.js requires a prefix of jqgh_
* as it is used as an id to the grid header
*/
if ( sort ) { $t.sortData('jqgh_' + colname, idx, reload); }
}
});
},
Please could this fix be included in future releases.
best regards and keep up the good work, Dave.
Most Users Ever Online: 715
Currently Online:
40 Guest(s)
Currently Browsing this Page:
2 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66