jquery - How to merge cells in jqGrid 4.0 -
i've been trying "merge" cells in jqgrid, is, want make cells specific rows have colspan=2 (or more). far i've been able borders work using cellattr option in column model this:
colmodel = { name: "a", width=50, cellattr: function(rowid, tv, rawobject, cm, rdata) { if (rowid < 5) { return 'sytle="border-right:0px"'; } }, name: "b", width=50, cellattr: function(rowid, tv, rawobject, cm, rdata) { if (rowid < 5) { return 'sytle="border-left:0px"'; } } }; this removes border cells want merge (a & b line 5). if add text of these boxes text-align not work , text gets cut off if larger 50 pixels.
i crazy thing center-align cutting text in half , add each half column "a" , "b" under right-align , left-align respectively. however, there seems there should better way.
i find question interesting, +1 me.
it seems me usage of colspan=2 need. have same number of columns in rows having colspan=2 suggest hide next <td> element in row:
{ name:'a',index:'a', width:50, cellattr: function(rowid, tv, rawobject, cm, rdata) { if (number(rowid) < 5) { return ' colspan=2' } } }, { name:'b',index:'b', width:50, cellattr: function(rowid, tv, rawobject, cm, rdata) { if (number(rowid) < 5) { return ' style="display:none;"' } } } i tested implementation few time, seems work:

the demo can see live here.
updated: another answer shows how can used rowspan attribute in jqgrid.
Comments
Post a Comment