protected void HandleChangeStatusTypeFilter(Syncfusion.Blazor.DropDowns.ChangeEventArgs<string> args)
{
var fieldsToClear = new List<string>
{
"Status",
};
if (args.Value == null)
{
Grid.ClearFiltering(fieldsToClear);
}
else
{
Grid.FilterByColumn("Status", "equal", args.Value, null, true);
}
}
|
on my group change all data vipes all maybe becausse of my filtering code which is dynamic .How Shall i handle grouping and filtering together by code
@page "/EmployeeManagement"
@using Syncfusion.Blazor.Grids
@rendermode InteractiveServer
<style>
.e-grid .e-gridheader .e-icons:not(.e-icon-hide):not(.e-check):not(.e-stop):not(.e-icon-reorderuparrow):not(.e-icon-reorderdownarrow){
color:transparent!important;
}
</style>
<h3>EmployeeManagement</h3>
<div style="max-width:900px">
<SfGrid TValue="EmployeeModel" AllowGrouping="true" DataSource="@employeeData" AllowSorting="true" AllowPaging="true" AllowFiltering="true" Toolbar="@toolbar" AutoGenerateColumns="true">
<GridPageSettings PageSize="8"></GridPageSettings>
<GridGroupSettings Columns="@Initialgroup" ShowDropArea="true" ShowToggleButton="true" ShowGroupedColumn="true" ShowUngroupButton="true" />
<GridFilterSettings Type="Syncfusion.Blazor.Grids.FilterType.Menu" Columns="@FilterableGridFilterColumns"></GridFilterSettings>
<GridEditSettings AllowAdding="true" AllowDeleting="true" AllowEditing="true"></GridEditSettings>
</SfGrid>
</div>
@code {
public List<GridFilterColumn> FilterableGridFilterColumns { get; set; } = new List<GridFilterColumn>();
private List<EmployeeModel>? employeeData = null;
private List<object> toolbar = new List<object> { "Add", "Edit", "Delete", "Update", "Cancel", "Search" };
public string[] Initialgroup = (new string[] { "Gender" });
protected override void OnInitialized()
{
GenerateEmployeeData();
var filterableColumns = new List<string> { "FirstName", "LastName" };
foreach (var columnName in filterableColumns)
{
var column = new GridFilterColumn { Field = columnName };
FilterableGridFilterColumns.Add(column);
}
}
private void GenerateEmployeeData()
{
employeeData = new List<EmployeeModel>();
for (int i = 1; i <= 10; i++)
{
EmployeeModel emp = new EmployeeModel
{
Id = i,
FirstName = "FirstName" + i,
LastName = "LastName" + i,
JobTitle = "JobTitle" + i,
Gender = i % 2 == 0 ? "Male" : "Female",
DateOfBirth = DateTime.Now.AddYears(-20).AddMonths(i),
ReportToEmpId = i > 3 ? 1 : (int?)null
};
employeeData.Add(emp);
}
}
public class EmployeeModel
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string JobTitle { get; set; }
public string Gender { get; set; }
public DateTime DateOfBirth { get; set; }
public int? ReportToEmpId { get; set; }
}
}
Hi Muhammad Waleed,
We have created a separate forum for your query. Kindly check the mentioned thread for further follow-ups.