Forum
02:26
18/09/2011
First of all, I'm a newbie in js & jqgrid.
I'm using jqGrid 4.2.0. I love jqgrid. I wish this can be fixed in the next version.
Yestoday, I want to use setLabel to change the column names of some column. I found two BUGs.
1. setLabel ONLY works with column names. But in the wiki, it said works with both names and ID.
2. when groupHeaders feature is used, eg. use setGroupHeaders to setup some group headers. setLabel works very strange.
after about 4 hours try and try, the BUG is found. I'm not sure on my modifications, so , I just add a new method named by setLabelByID. original function is leaved not changed. In my project, I use setLabelByID only.
setLabel : function(colname, nData, prop, attrp ){
return this.each(function(){
var $t = this, pos=-1;
if(!$t.grid) {return;}
if(typeof(colname) != "undefined") {
$($t.p.colModel).each(function(i){
if (this.name == colname) {
pos = i;return false;
}
});
} else { return; }
if(pos>=0) {
// th:eq pos error when groupHeaders exists.
var thecol = $("tr.ui-jqgrid-labels th:eq("+pos+")",$t.grid.hDiv); //maybe this selector is wrong when groupHeaders is used
if (nData){
var ico = $(".s-ico",thecol);
$("[id^=jqgh_]",thecol).empty().html(nData).append(ico);//maybe this line is wrong. I'm not sure.
$t.p.colNames[pos] = nData;
}
if (prop) {
if(typeof prop === 'string') {$(thecol).addClass(prop);} else {$(thecol).css(prop);}
}
if(typeof attrp === 'object') {$(thecol).attr(attrp);}
}
});
},
setLabelByID: function (pos, nData) {
return this.each(function () {
var $t = this;
if (!$t.grid) { return; }
if (pos >= 0 ) {
//this works well.
var thecol = $("#jqgh_"+ $t.id + '_'+$t.p.colModel[pos].name, $t.grid.hDiv);
if (nData) {
var ico = $(".s-ico", thecol);
thecol.empty().html(nData).append(ico);
$t.p.colNames[pos] = nData;
}
}
});
},
Best regards.
Most Users Ever Online: 715
Currently Online:
34 Guest(s)
Currently Browsing this Page:
1 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