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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Dynamically set and unset column type checkbox

Thread ID:

Created:

Updated:

Platform:

Replies:

127881 Dec 15,2016 10:25 AM UTC Dec 16,2016 02:42 PM UTC ASP.NET Web Forms 1
loading
Tags: Grid
Semper
Asked On December 15, 2016 10:25 AM UTC

Hi,

i have a grid with single row selection.
On a button i dynamically show a column (<ej:Column Width="50" Visible="false"></ej:Column>)
and set it's type property to checkbox

var obj = $("#GridMaster").ejGrid("instance");
    obj.model.columns[1].type = "checkbox"
    obj.model.columns[1].visible = true;
    obj.refreshTemplate();

It all works well and i can then select multiple rows via checkbox column.
But when i try to revert back to single selection however i cannot select any rows because the grid still waits for rows to be selected by checkbox column which is now hidden and it's type is null as it was when the grid was first created.
This is the code:
 if (obj.model.columns[1].type == "checkbox") {
        obj.model.columns[1].type = null;
        obj.model.columns[1].visible = false;
        obj.model.selectionType = "single"
        obj.model.enableAutoSaveOnSelectionChange = true;
        obj.model.selectionSettings.enableToggle = false;
        obj.refreshTemplate();
};

How to achieve this to work?


Venkatesh Ayothi Raman [Syncfusion]
Replied On December 16, 2016 02:42 PM UTC

Hi Semper, 

Thanks for contacting Syncfusion support. 

We went through the code example that you have shared for us and found that missed to disable the property of _enableCheckSelect in Grid. We have enabled the property when we enabling the checkbox column. So we suggest you to disable that property like as follows, 
Code example
<script> 
        $("#show").click(function () { 
             
            var gridObj = $(".e-grid").ejGrid('instance'); 
 
            gridObj.model.columns[0].type = "checkbox"; 
            
            gridObj.model.columns[0].visible = true; 
            
            gridObj.refreshContent(true); 
        }) 
 
        $("#hide").click(function () { 
 
            var gridObj = $(".e-grid").ejGrid('instance'); 
 
            gridObj.model.columns[0].type = null; 
            gridObj.model.columns[0].visible = false; 
            gridObj.model.selectionType = "single"; 
            gridObj._enableCheckSelect = false; // disable the checkbox property in Grid 
            gridObj.refreshContent(true); 
        }) 
    </script> 

Regards, 
Venkatesh Ayothiraman. 


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

;