Easyui automatically merge cells dynamically

Source: Internet
Author: User

Onloadsuccess:function(data) {if(Data.rows.length > 0) { //call Mergecellsbyfield () to merge cellsMergecellsbyfield ("Grid", "Supply_fullname,in_supply,in_no,in_sales"); } }functionMergecellsbyfield (TableID, collist) {//alert (tableid+ "" +collist); varColarray = Collist.split (","); varttable = $ ("#" +TableID); varTablerowcnts = Ttable.datagrid ("GetRows"). length; varTmpa; varTMPB; varPertxt = ""; varCurtxt = ""; varAlertstr = ""; for(j = colarray.length-1; J >= 0; j--) {Pertxt= ""; Tmpa= 1; TMPB= 0; for(i = 0; I <= tablerowcnts; i++) { if(i = =tablerowcnts) {Curtxt= ""; } Else{curtxt= Ttable.datagrid ("GetRows") [I][colarray[j]]; } if(Pertxt = =curtxt) {Tmpa+ = 1; } Else{TMPB+=Tmpa; Ttable.datagrid ("MergeCells", {index:i-Tmpa, Field:colarray[j],//merge FieldsRowspan:tmpa, colspan:NULL }); Ttable.datagrid ("MergeCells", {//merge according to Colarray[j]INDEX:I-Tmpa, field:"Ideparture", Rowspan:tmpa, colspan:NULL }); Tmpa= 1; } pertxt=Curtxt; } }}

This is a 2-segment code,

1, in the Onloadsuccess method in the Easyui DataGrid, call Mergecellsbyfield (TableID, collist), parameter TableID is the ID of the table, collist The fields for the cells that need to be merged are "," split,

2, for Mergecellsbyfield () method

Easyui automatically merge cells dynamically

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.