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

Enable/disable adjacent cell based on checkbox value

How to Enable/disable adjacent cell based on checkbox value. I have a clolumn with checkboxes and Mothcaleder column just beside it.
What I want is when the checkbox is not check for month calendar cell on the same roe to be disabled/read only etc. When user checks the checkbox I want the calendar cell beside to be enabled/full write etc.
Mariusz


3 Replies

AA Arulraj A Syncfusion Team January 17, 2019 02:20 AM

Hi Mariusz, 

Thanks for using Syncfusion product. 

To make the cell as read only based on another cell value in the same row, you could use the Style.Enabled property in QueryCellStyleInfo event. Please refer the following code example. 

C# 
this.gridGroupingControl1.QueryCellStyleInfo += GridGroupingControl1_QueryCellStyleInfo; 
 
 
private void GridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e) 
{ 
    if (e.TableCellIdentity == null || e.TableCellIdentity.Column == null) 
        return; 
 
    if (e.TableCellIdentity.Column.Name == "Date" && e.TableCellIdentity.DisplayElement.Kind == Syncfusion.Grouping.DisplayElementKind.Record) 
    { 
        Record record = e.TableCellIdentity.DisplayElement.GetRecord(); 
        if (record != null) 
        { 
            var value = record.GetValue("Boolean"); 
            if (value != null) 
            { 
                int v; 
                if (int.TryParse(value.ToString(), out v) && v <= 0) 
                    e.Style.Enabled = false; 
            } 
        } 
    } 
} 
 
 
Arulraj A 



MJ Mariusz Juszkiewicz January 17, 2019 10:35 PM

Arulraj Thank you,

if (int.TryParse(value.ToString(), out v) && v <= 0)
was giving me trouble in my application. I have used
if (!Convert.ToBoolean(value.ToString()))
it seems to work.


AA Arulraj A Syncfusion Team January 17, 2019 11:41 PM

Hi Mariusz,

Thanks for the update.

Please feel free to contact us in case of any further difficulty. We'll be glad to assist you.

Regards,
Arulraj A

Loader.
Live Chat Icon For mobile
Up arrow icon