07 Feb, 2007
yui-ext: Field names instead of column id’s
Posted by: Enrico Stahn In: Software Development
You’re using the Grid of yui-ext and you’re loading the data with XMLDataModel, JSONDataModel or any other kind of LoadableDataModel, right? Well, did you tried to use the remoteSort configuration and got worried about this feature as you’re recognize it sends the column index instead of the field name?
Instead of rewrite parts of yui-ext, use the following code after you’ve loaded yui-ext. Now, you should get the field name.
YAHOO.ext.grid.LoadableDataModel.prototype.createParams = function(pageNum, sortColumn, sortDir) {
var params = {}, map = this.paramMap;
for(var key in this.baseParams){
if(typeof this.baseParams[key] != 'function'){
params[key] = this.baseParams[key];
}
}
params[map['page']] = pageNum;
params[map['pageSize']] = this.getPageSize();
params[map['sortColumn']] = (typeof sortColumn == 'undefined' ? '' : this.schema.fields[sortColumn]);
params[map['sortDir']] = sortDir || '';
return params;
}