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. Image for the cookie policy date
close icon

GridData - how to dynamically show/hide or enable cells per row?

Hallo,

I have created a GridDataControl where each row consist of several cells containing regular text fields and check boxes that can be edited by the user.

Now, for some rows, depending on the contained data, one of the check boxes is not applicable, so I would like to either hide it (show an empty cell) or at least disable it on these rows. What is the best way to achieve this?

Thanks for your help!
Walter

1 Reply

KR Kannan R Syncfusion Team December 5, 2012 11:44 AM UTC

Hi Walter,

 

Thanks for using Syncfusion products.

 

We have analyzed your query with our sample and your requirement can be achieved by handling QueryCellInfo event, please find below code snippet to achieve your requirement.

 

Code Snippet[C#]:

 

  
 
 void Model_QueryCellInfo(object sender, GridQueryCellInfoEventArgs e)

        {

 

            if (e.Cell.RowIndex > 0 && e.Cell.ColumnIndex == 1)

            {

                if (e.Style.CellValue == "true" || e.Style.CellValue == "false")

                {

                    e.Style.CellType = "CheckBox"// Setting celltype as checkbox

                    e.Style.IsThreeState = false;

                }

                else

                {

                    e.Style.Enabled = false;   //To Disable the cell.

                    e.Style.CellValue = "";      //To display as empty cell.

                }

 

            }

 

        }

 

 

 

We have also prepared sample based on your requirement and it can be downloaded from below location.

Sample Location:  105654ForumSample.zip

Please let us know if you have any queries.

 

Thanks,

Kannan.R


Loader.
Live Chat Icon For mobile
Up arrow icon