PDA

View Full Version : Cannot display 0 in grid



alcarx
16 Oct 2006, 2:08 AM
a column such as id, cannot display 0, but can display other numbers such as 1, 2

don't know whether it is because
in JSONDataModel.js, loadData, var val = node[fields[j]]|| ""
..


I am not very familiar with javascript, thanks

..Solved this by using a custom renderer

jack.slocum
16 Oct 2006, 2:54 AM
Here's a patch. Thanks for reporting it.



YAHOO.ext.grid.JSONDataModel.prototype.loadData = function(data, callback, keepExisting){
var idField = this.schema.id;
var fields = this.schema.fields;
var rowData = [];
try{
var root = eval('data.' + this.schema.root);
for(var i = 0; i < root.length; i++){
var node = root[i];
var colData = [];
colData.node = node;
colData.id = (typeof node[idField] != 'undefined' && node[idField] !== '' ? node[idField] : String(i));
for(var j = 0; j < fields.length; j++) {
var val = node[fields[j]];
if(typeof val == 'undefined'){
val = '';
}
if(this.preprocessors[j]){
val = this.preprocessors[j](val);
}
colData.push(val);
}
rowData.push(colData);
}
if(keepExisting !== true){
this.removeAll();
}
this.addRows(rowData);
if(typeof callback == 'function'){
callback(this, true);
}
this.fireLoadEvent();
}catch(e){
this.fireLoadException(e, null);
if(typeof callback == 'function'){
callback(this, false);
}
}
};