Hi,
I got the following code from your site.
1- How do I implement the following image?
2. To read data from Web Api ,I used CustomAdaptor. How can I implement ValueChange = "OnValueChange"?
@using Syncfusion.Blazor.Buttons
@using BlazorDemos
@using blazor_griddata
@inherits SampleBaseComponent;
<div class="col-lg-12 control-section">
<div class="content-wrapper">
<div class="row">
<SfGrid @ref="Grid" DataSource="@GridData" AllowFiltering="true" AllowPaging="true">
<GridPageSettings PageCount="5"></GridPageSettings>
<GridColumns>
<GridColumn Field="@nameof(Category.CategoryName)" AutoFit="true"
AllowEditing="true" TextAlign="TextAlign.Right"
HeaderTextAlign="TextAlign.Center" Type="ColumnType.String"
FilterSettings="@(new FilterSettings { Operator =Syncfusion.Blazor.Operator.Contains})">
</GridColumn>
<GridColumn Field=@nameof(Category.CategoryName) HeaderText="Category Name" TextAlign="TextAlign.Right" Width="120" FilterSettings="@(new FilterSettings { Operator =Syncfusion.Blazor.Operator.Contains })"></GridColumn>
<GridColumn Field=@nameof(Category.ProductName) HeaderText="Product Name" Width="150" FilterSettings="@(new FilterSettings { Operator =Syncfusion.Blazor.Operator.Contains })"></GridColumn>
<GridColumn Field=@nameof(Category.QuantityPerUnit) HeaderText="Quantity Per Unit" TextAlign="TextAlign.Right" Width="120" FilterSettings="@(new FilterSettings { Operator =Syncfusion.Blazor.Operator.Contains })"></GridColumn>
<GridColumn Field=@nameof(Category.UnitsInStock) HeaderText="Units In Stock" Width="150" TextAlign="TextAlign.Right" FilterSettings="@(new FilterSettings { Operator =Syncfusion.Blazor.Operator.Contains })"></GridColumn>
<GridColumn Field=@nameof(Category.Discontinued) HeaderText="Discontinued" Width="150" TextAlign="TextAlign.Center" Type="ColumnType.Boolean">
<FilterTemplate>
@{
var FilterContext = (context as PredicateModel);
bool? fValue = string.IsNullOrEmpty(FilterContext.Value.ToString()) ? null : (bool?)FilterContext.Value;
}
<SfCheckBox Checked="@fValue" EnableTriState="true" ValueChange="OnValueChange" TChecked="bool?"></SfCheckBox>
</FilterTemplate>
</GridColumn>
</GridColumns>
</SfGrid>
</div>
</div>
</div>
@code{
public SfGrid<Category> Grid { get; set; }
public List<Category> GridData { get; set; }
protected override void OnInitialized()
{
GridData = Category.GetAllRecords();
}
private async Task OnValueChange(ChangeEventArgs<bool?> args)
{
if (args.Checked != null)
await Grid.FilterByColumn("Discontinued", "equal", args.Checked); //Perform filtering while check/uncheck the checkbox
else
await Grid.ClearFiltering("Discontinued");
}
}
Hi Sarah,
Greetings from Syncfusion support.
We understand your requirement and prepared a sample using your code example. We are successfully able to perform filtering action in Boolean column using Filter Checkbox. Are you facing issues with this implementation. If yes share the following details.
The above requested details will be very helpful for us to validate the reported query at our end and provide a solution as early as possible.
Regards,
Vignesh Natarajan
Hi Vignesh Natarajan ,
in first step. I looked at the source code of the site and used it to implement the image on the left. I could not implement the image on the right. To replace the cell values (true, false) with a check box.
thank you
Hi Sarah,
Greetings from Syncfusion.
We have checked your query and we are quite unclear about the exact issue you are facing. kindly share the below details to validate further at our end.
The above-requested details will be very helpful for us to validate the reported query at our end and provide the solution as early as possible.
Regards,
Monisha
Hi,
With your guidance, I used DisplayAsCheckbox. The bug was fixed.
thank you
Hi Sarah,
Welcome.
Kindly get back to us if you have further queries. As always we will be happy to help you.
Regards,
Monisha