How to merge header cell in grid for asp.net forms

Hi,

I tried to merge two columns of header into one column.  I read through other forums, it says it needs to use MergeHeaderCellInfo.
MergeHeaderCellInfo="function(args){args.headerCellMerge(1,2); }"

Even I used MergeHeaderCellInfo, it doesn't work.

I attach my sample solution.  Could you please tell me what is wrong?
I want to show header like this below
I just want to combine first_name column and last_name column into name only for header.


memberIdnamestart date

Best Regards,
Yukiko

Attachment: test_72370443.7z

3 Replies

PK Prasanna Kumar Viswanathan Syncfusion Team August 23, 2018 11:12 AM UTC

Hi Yukiko, 

Thanks for using Syncfusion products. 

Based on your query we found that you need to merge two header cells in Grid. We checked the provided sample and we found that you have defined the function directly in MergeHeaderCellInfo event which is the cause of an issue. We have to define the function name alone in the ClientSideEvents and its method separately.  

Refer the below code example 

<ej:Grid ID="Grid1" runat="server" AllowPaging="True"  DataSourceID="test34" ClientIDMode="AutoID"  OnServerAddRow="Grid1_ServerAddRow" AllowCellMerging="true" AllowGrouping="true"  OnServerEditRow="Grid1_ServerEditRow"  AllowSorting="true">  
        <EditSettings AllowEditing="true"  AllowAdding="true"  AllowDeleting="true" AllowEditOnDblClick="false"    /> 
         <ClientSideEvents ActionBegin="onbegin" MergeHeaderCellInfo="mergeHead" RowSelected="rowselect"/>          
.                      .              .             .            .  
</ej:Grid> 
.                          .                         .                      .  

<script type="text/javascript"> 
 
.                       .                      .                     .                .  
 
    function mergeHead(args) { 
        args.headerCellMerge(1, 2); 
    } 
 
 
</script> 

Refer the below screenshot for the output 

 

For your convenience we have prepared a sample which can be downloaded from below link 

  
Regards, 
Prasanna Kumar N.S.V 
 



YI Yukiko Imazu August 23, 2018 01:20 PM UTC

Hi Prasanna,

Thank you so much for your help.
I could resolve my issue.

Best Regards,
Yukiko


PK Prasanna Kumar Viswanathan Syncfusion Team August 23, 2018 04:32 PM UTC

Hi Yukiko, 

We are happy to hear that your issue has been resolved. 

Please get back to us if you need any further assistance. 

Regards, 
Prasanna Kumar N.S.V 


Loader.
Up arrow icon