Easyui DataGrid Merge Cells
1 functionMergeCells () {2 varArr =[{mergefiled: "Field", Premisefiled: ""}];////Merge column field array and corresponding prerequisites filed (empty is the direct content merge)3 vardg = $ ("#id");//The table ID in the DataGrid to be merged4 varRowCount = Dg.datagrid ("GetRows"). length; 5 varCellname; 6 varspan; 7 varPervalue = ""; 8 varCurvalue = ""; 9 varPercondition= ""; Ten varCurcondition= ""; One varflag=true; A varCondiname= ""; - varLength = Arr.length-1; - for(i = length; I >= 0; i--) { theCellname =arr[i].mergefiled; -Condiname=arr[i].premisefiled; - if(!condiname) { -flag=false; + } -Pervalue = ""; +Percondition= ""; Aspan = 1; at for(row = 0; row <= rowCount; row++) { - if(Row = =RowCount) { -Curvalue = ""; -Curcondition= ""; -}Else { -Curvalue = Dg.datagrid ("GetRows") [Row][cellname]; in /*if (cellname== "Orgstarttime") {//Special handling this time field - curvalue =formatdate (Dg.datagrid ("getRows") [Row][cellname], ""); to } */ + if(!flag) { -Curcondition=dg.datagrid ("GetRows") [Row][condiname]; the } * } $ if(Pervalue = = curvalue&& (flag| | percondition==curcondition)) { Panax Notoginsengspan + = 1; -}Else { the varindex = row-span; +Dg.datagrid (' MergeCells ', { A Index:index, the Field:cellname, + Rowspan:span, -colspan:NULL $ }); $span = 1; -Pervalue =Curvalue; - if(!flag) { thepercondition=curcondition; - } Wuyi } the } - } Wu } - About //<table id= "deviceserieses" class= "Easyui-datagrid" data-options= "Onloadsuccess:mergecells" ></table >
Make column selection in outer table does not change color use the Styler property of the column.
Easyui DataGrid Merge Cells