Forum
22:49
03/12/2010
I have a grid where one of the columns contain html code. Everything works fine until the html code within the column data contains a table, in which case I get a js exception: "g.p.colModel[a] is undefined". In the src, I narrowed it down to the following and created a work around that seems to work:
…
getRowData : function( rowid ) {
var res = {}, resall, getall=false, len, j=0;
this.each(function(){
var $t = this,nm,ind;
if(typeof(rowid) == 'undefined') {
getall = true;
resall = [];
len = $t.rows.length;
} else {
ind = $t.rows.namedItem(rowid);
if(!ind) { return res; }
len = 2;
}
while(j<len){
if(getall) { ind = $t.rows[j]; }
if( $(ind).hasClass('jqgrow') ) {
$('td',ind).each( function(i) {
try {
nm = $t.p.colModel[i].name;
if ( nm !== 'cb' && nm !== 'subgrid' && nm !== 'rn') {
if($t.p.treeGrid===true && nm == $t.p.ExpandColumn) {
res[nm] = $.jgrid.htmlDecode($("span:first",this).html());
} else {
try {
res[nm] = $.unformat.call($t,this,{rowId:ind.id, colModel:$t.p.colModel[i]},i);
} catch (e){
res[nm] = $.jgrid.htmlDecode($(this).html());
}
}
}
} catch(e) {
}
});
if(getall) { resall.push(res); res={}; }
}
j++;
}
});
return resall ? resall: res;
},…
The bold line is the code that is triggering the exception. The italic bold code is my work around that I added. My question is: Is my work around "safe" and/or is there a better way to accomplish this?
I tried creating a small stand-alone example but for some reason, my small example works. I think it may be related to the datatype of json — my small example cannot fully impliment this without creating a scripting dependancy — a hard coded html template for the getter is not cutting it. I can send what I have if it helps.
23:06
03/12/2010
12:14
Moderators
30/10/2007
Hello,
There is nothing bad with your fix, but before to implenent it it will bereally good to have a test case.
Thank you
Regards
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Most Users Ever Online: 715
Currently Online:
40 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