ahmed salah

ahmed salah

  • 1.2k
  • 547
  • 64.2k

Issue filter ridzen data grid not get data after filter based on Query

Jul 25 2023 10:41 AM

I work on blazor server side .asp.net core 7 . I face issue I can't return data after filter from list on Radzen data grid

First I create radzen data grid on razor page

<RadzenDataGrid @ref="myDataGrid"  AllowColumnPicking="true" FilterMode="FilterMode.Simple" AllowFiltering="true" PageSizeOptions="@PagingOptions" FilterCaseSensitivity="FilterCaseSensitivity.CaseInsensitive" 
                                                data="@databaseData" >

second I create list that receive data after filter

private IEnumerable<CopyExcelDatabaseClass> databaseData = Array.Empty<CopyExcelDatabaseClass>();

    public class CopyExcelDatabaseClass
    {
     
        public string databaseName { get; set; }
        public int serverID { get; set; }
        public string serverName { get; set; }
        public string severity { get; set; }


    }

third function is filter list based on dynamic condition get it from myDataGrid.Query.Filter

public void getListDataAfterFilter()
{
 var query = myDataGrid.Query.Filter;
 var filteredList = databaseData.Where(query).ToList();
}

this statement return condition Filter from radzen data grid after write filters

var query = myDataGrid.Query.Filter; 
return below filter condition

(databaseName == null ? "" : databaseName).ToLower().Contains("Menna".ToLower()) and (serverity == null ? "" : serverity).ToLower().Contains("Mon".ToLower())

I try to get result from above and it worked fine

var filteredList = databaseData.Where(item => item.databaseName.Contains("DB_U")).ToList();

but issue it static and I need it dynamically meaning based on condition filter Query.Filter


Answers (2)