jqgrid合并单元格(准确的说是设置单元格的样式)

//假如strData.HeBing的数据如下:["1,3","7,8","9,15","17,18"],至少有五列 shi ,xianqu,qiyemingcheng,shifoulianwang,qiyejibie
gridComplete: function () {
                    //表格加载执行合并
                    var willToMerge = eval(strData.HeBing);
                    var num = willToMerge.length;
                    if (willToMerge != null && num > 0)
                    {
                        for (var i = 0; i < num; i++) {
                            var t=willToMerge[i];
                            var x=t.split(",");
                            var startRow=parseInt(x[0]);
                            var endRow = parseInt(x[1]);
                            var rowspanv = endRow - startRow + 1;
                            for(var z=startRow+1;z<=endRow;z++)
                            {
                                $("#datagrid").setCell(z, 'shi', '', { display: 'none' });
                                $("#datagrid").setCell(z, 'xianqu', '', { display: 'none' });
                                $("#datagrid").setCell(z, 'qiyemingcheng', '', { display: 'none' });
                                $("#datagrid").setCell(z, 'shifoulianwang', '', { display: 'none' });
                                $("#datagrid").setCell(z, 'qiyejibie', '', { display: 'none' });
                            }
                            $("#datagrid").setCell(startRow, 'shi', '', '', { rowspan: rowspanv });
                            $("#datagrid").setCell(startRow, 'xianqu', '', '', { rowspan: rowspanv });
                            $("#datagrid").setCell(startRow, 'qiyemingcheng', '', '', { rowspan: rowspanv});
                            $("#datagrid").setCell(startRow, 'shifoulianwang', '', '', { rowspan: rowspanv  });
                            $("#datagrid").setCell(startRow, 'qiyejibie', '', '', { rowspan: rowspanv});
                        }
                    }
                }

你可能感兴趣的:(jqgrid合并单元格(准确的说是设置单元格的样式))