Is there a way to disable the Blazor grid's checkbox that is used for selecting a row?

I have a requirement where I need to disable row checkboxes that have a certain status.  Is there a way to use a template to disable the checkbox based on the status?  Do I need to handle this on the row selecting event?

1 Reply 1 reply marked as answer

VN Vignesh Natarajan Syncfusion Team July 30, 2020 06:11 PM UTC

Hi Brian,  
 
Greetings from Syncfusion support.  
 
Query: “ have a requirement where I need to disable row checkboxes that have a certain status. 
 
We suggest you to achieve your requirement (disable checkbox based on row value) by using QueryCellInfo event of Grid and AddClass() method to disabled the checkbox using CSS styles. Refer the below code example.  
 
<SfGrid @ref="DefaultGrid" DataSource="@Orders" AllowPaging="true">    <GridEvents QueryCellInfo="QueryCellInfoHandler" TValue="Order"></GridEvents>    <GridColumns>        <GridColumn Type="ColumnType.CheckBox" Width="60"></GridColumn>        <GridColumn Field=@nameof(Order.OrderID) HeaderText="Order ID" TextAlign="TextAlign.Right" Width="120" IsPrimaryKey="true"></GridColumn>        <GridColumn Field=@nameof(Order.CustomerID) HeaderText="Customer Name" Width="150"></GridColumn>        <GridColumn Field=@nameof(Order.OrderDate) HeaderText=" Order Date" Format="d" Type="ColumnType.Date" TextAlign="TextAlign.Right" Width="130"></GridColumn>        <GridColumn Field=@nameof(Order.Freight) HeaderText="Freight" Format="C2" TextAlign="TextAlign.Right" Width="120"></GridColumn>    </GridColumns></SfGrid> <style>    .e-checkbox-disabled .e-checkbox-wrapper .e-frame {        border-color#bdbdbd;    }     .e-checkbox-disabled .e-checkbox-wrapper {        cursordefault;        pointer-eventsnone;    }</style> @code{    public List<Order> Orders { getset; }    public void QueryCellInfoHandler(QueryCellInfoEventArgs<Order> Args)    {        if (Args.Column.Type == ColumnType.CheckBox && (Args.Data.CustomerID == "ALFKI" || Args.Data.CustomerID == "ANTON"))        {            Args.Cell.AddClass(new string[] { "e-checkbox-disabled" });        }     }
 
   
Kindly download the sample from below  
 
 
Refer our UG documentation for your reference 
 
 
Kindly get back to us if you have further queries.  
 
Regards,
Vignesh Natarajan
 


Marked as answer
Loader.
Up arrow icon