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

Columns filters not showing all available options: search not working

Hi,

We have a fairly urgent problem to resolve with the Grid control. The columns filters only show  a subset of the available options in each column to filter on (5 + all)  - and there does not seem to be any way to control this. If we could boost this up to 10 it would meet our need. The Search facility on the filter columns also does not seem to be working for any of the filter styles - we can trace the requests back to the datasource and see that it is returning the correct results to the grid, but the filter box in the grid seems to ignore that an always just shows "No Results Found" no matter what the search term is.
 


15 Replies

CS Charles Southey December 20, 2018 11:25 PM UTC

I have partially got to the bottom of this: it appears that the grid samples the first 1,000 records to get values for the filters: we have put our own filters to restrict the data set so it does not go over that. However we still have the problem with the search not working - and it would be helpful to get more information server-side on data retrievals triggered by opening a filter list so we can control how the filter list gets its data  (and make it much more efficient).  Simply grabbing all the data every time is a very inefficient way of doing this -we can write server-side code that intelligently supplies the right values.



MS Madhu Sudhanan P Syncfusion Team December 21, 2018 10:35 AM UTC

Hi Charles, 

Greetings from Syncfusion. 

Query #1: Simply grabbing all the data every time is a very inefficient way of doing this -we can write server-side code that intelligently supplies the right values. 
 
We have validated your query and we suggest to use the addParams method of the query property to achieve your requirement. In the below sample, using actionBegin event when requestType is filterbeforeopen we have passed a variable and in the controller based on this value you can change datasource provided to create the filter items in excel filter. Please refer to below sample and documentation for your reference, 

Code Example:  

[.cshtml] 
... 
function begin(args) { 
        if (args.requestType == 'filterbeforeopen') { 
            cloneQuery = this.query; 
            this.query = new ej.data.Query().addParams("excelfilter", true); 
        } 
    }... 
[.cs] 
... 
if (dm.excelfilter
            { 
                DataSource = operation.PerformTake(DataSource, 2);    //we have just passed the first two records to the excel filter items 
                //You can change the filter data according to your requirement here 
            } 
... 



Query #2: The Search facility on the filter columns also does not seem to be working for any of the filter styles - we can trace the requests back to the datasource and see that it is returning the correct results to the grid, but the filter box in the grid seems to ignore that an always just shows "No Results Found" no matter what the search term is. 

Before we start working on this query, please provide the below mentioned information or details. It will help us provide better solution as soon as possible, 

  1. not seem to be working for any of the filter styles” here what do you mean by ‘filter styles’, please explain in detail on this?
  2. By default ‘number’ and ‘date’ fields are set with ‘equal’ operator while searching from excel filter, so please provide more details about the fields?
  3. Please share your full grid server and client side code example?
 
Regards, 
Madhu Sudhanan P 



MA Marcos December 23, 2020 08:21 PM UTC

Hello everyone, this is my issue right now using the last version. The issue its in the filter of cuorse
You can see Access Staffing at first row.
But not appear on the filter until you type that option

Once you type the option:


Thanks for any help you can provide to me.

Regards, Marcos




RR Rajapandi Ravi Syncfusion Team December 24, 2020 12:02 PM UTC

Hi Charles, 

Thanks for the update 

We have analyzed your query and we could see that you like to show the different choices which was exist in the datasource. By default the Excel filter in the Grid will display the data from the first 1000 records to optimize performance. The other records will be returned as result in the search option of the Filter dialog. This is the default behavior of Grid.  

You can increase the Excel filter count by modifying the filterChoiceCount argument value in the actionBegin event when the requestType is ‘filterchoicerequest’ as demonstrated in the below code snippet, 

// Grid’s actionBegin event function 
function onActionBegin(args) { 
        if (args.requestType === "filterchoicerequest") {‘ 
            // Filter choice count is modified 
            args.filterChoiceCount = 1500;  //modify value here as you want 
        } 
} 

Or we can achieve this requirement by using custom dataSource (Distinct value dataSource) for required filter column.  If you are using remote data , we suggest you to return the unique values from the server. To return the unique value from server side you have to create a select query in actionBegin event. Please refer the below code example for more information. 
 
 
<script> 
    function begin(args) { 
       if (args.requestType === "filterchoicerequest") { 
            var filterfields = []; 
            var objFilter = Object.keys(args.filterModel.existingPredicate); 
            for (var i = 0; i < objFilter.length; i++) { 
                filterfields.push(objFilter[i]); 
            } 
            filterfields.push(args.filterModel.options.field); 
            args.query.distincts = []; 
            args.query.select(filterfields); // Created the select query   
        } 
 
    } 
</script> 
 

 
 
public IActionResult UrlDatasource([FromBody]DataManagerRequest dm) 
        { 
            IEnumerable DataSource = order; 
            DataOperations operation = new DataOperations(); 
. . . . . . . .  
            int count = DataSource.Cast<Orders>().Count(); 
            if (dm.Select != null) 
            { 
                DataSource = operation.PerformSelect(DataSource, dm.Select);  // Selected the columns value based on the filter request  
                DataSource = DataSource.Cast<dynamic>().Distinct().AsEnumerable(); // Get the distinct values from the selected column  
            } 
. . . . . .  
            return dm.RequiresCounts ? Json(new { result = DataSource, count = count }) : Json(DataSource); 
        } 
 


Regards, 
Rajapandi R 



RO Rodrigo replied to Rajapandi Ravi March 25, 2022 03:48 AM UTC

Hi, i've been trying to apply this feature, but haven't been able to.


For example, on column Status, i have 10 options: from Status A, Status B, till Status J.

distinct on table.png


Issue 1: When i display the filter, the Status B is missing:


only filter popup.png


But, if i check the function, the Status B is also missing: