How to merge cells in jqGrid 4.0

后端 未结 2 1946
悲哀的现实
悲哀的现实 2020-11-28 15:23

I\'ve been trying to \"merge\" cells in a jqGrid, that is, I want to make cells for specific rows have a colspan=2 (or more). So far I\'ve been able to get the borders to wo

2条回答
  •  醉话见心
    2020-11-28 15:58

    I find your question very interesting, so +1 from me.

    It seems to me that the usage of colspan=2 is what you really need. To have the same number of the columns in the rows having colspan=2 I suggest to hide the next element in the 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 the implementation only a few time, but it seems to work:

    enter image description here

    The demo you can see live here.

    UPDATED: Another answer shows how can be used rowspan attribute in jqGrid.

提交回复
热议问题