We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Conditional cell merging

Thread ID:

Created:

Updated:

Platform:

Replies:

128484 Jan 25,2017 01:40 PM UTC Jan 27,2017 10:08 AM UTC JavaScript 1
loading
Tags: ejGrid
Kumaran
Asked On January 25, 2017 01:40 PM UTC

Hi,

I want to merge cells in both direction based on cell value like below example.

Col1 Col2 Col3 Col4
0 0 0 1
1 2
2 3
1 3 4
4 5

In Col2, row1 & row2 can be merged only if Col1 value is same. I tried to do this using mergeCellInfo event. Am able to merge row1 & row1 for Col1. AM not able to add the row3 to the already merged cell. What is the right approach to do this ? 

Thanks
Kumaran



Alan Sangeeth S [Syncfusion]
Replied On January 27, 2017 10:08 AM UTC

Hi Kumaran, 

To add a row to the already merged cell, traverse to the sibling element which has defined ‘rowSpan’ attribute and modify its value. Please refer the following code example. 
$("#Grid").ejGrid({ 
 
mergeCellInfo: function (args) { 
                             
if (args.data.EmployeeID == 10005) { 
 if (args.column.field == "9:00" && args.data[args.column.field] == "Check Mail"){ 
  var cellEle =getParentElement($(args.cell)); 
   var rowSpan = cellEle.attr("rowSpan"); 
  cellEle.attr("rowSpan", ++rowSpan); 
 } 
} 
                } 
            }); 
        }); 
        function getParentElement(cell) { 
            var index = cell.index(); 
            var cellEle = cell.closest("tr").prev("tr").find("td").eq(index); 
            if (cellEle.hasClass("e-hide")) 
                return getParentElement(cellEle); 
            else 
                return cellEle; 
        } 


For your convenience, we have created a sample and the same be downloaded from below location 


Regards,
Alan Sangeeth S 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;