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:

only filter.png



Issue 2: if i apply a search, for example Client 5023, the filter function is not displaying any option (shows error). Also if i type anything also shows error.

filter after search popup 2.png


I set the property args.filterChoiceCount = 3000; because an upper number gives me a Json max lenght error.


Thank you very much for your help.



Attachment: SyncfusionMvcApplication2_8401ead2.7z



RR Rajapandi Ravi Syncfusion Team March 25, 2022 01:15 PM UTC

Hi Rodrigo, 

Thanks for the update. 

Currently, we are validating your query with your shared information, and we will update you the details on or before 29th March 2022. Until then we appreciate your patience. 

Rajapandi R 




RO Rodrigo replied to Rajapandi Ravi March 31, 2022 05:42 AM UTC

Hi Rajapandi, looking forward to the update. Thank you very much.


Regards,



RR Rajapandi Ravi Syncfusion Team March 31, 2022 03:21 PM UTC

Hi Rodrigo,


Thanks for your patience


Query#: When i display the filter, the Status B is missing


We have checked your shared sample and we found that you are defining the dm.select query after the skip and take, it will get the distinct records only for the current page record. So that the Status B was missing, it was the cause of the problem. To avoid the problem, we suggest you define the select query before the skip and take executes. Please refer the below code example and sample for more information.


 

public ActionResult UrlDatasource(DataManagerRequest dm)

        {

            IEnumerable DataSource = db.proposals.OrderByDescending(x => x.codigo).ToList();

            DataOperations operation = new DataOperations();

            if (dm.Search != null && dm.Search.Count > 0)

            {

                DataSource = operation.PerformSearching(DataSource, dm.Search);  //Search

            }

            if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting

            {

                DataSource = operation.PerformSorting(DataSource, dm.Sorted);

            }

            if (dm.Where != null && dm.Where.Count > 0) //Filtering

            {

                DataSource = operation.PerformFiltering(DataSource, dm.Where, dm.Where[0].Operator);

            }

            int count = DataSource.Cast<proposals_Model>().Count();

//define the select query before the paging skip and take execute

            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 

            }

             if (dm.Skip != 0)

            {

                DataSource = operation.PerformSkip(DataSource, dm.Skip);   //Paging

            }

            if (dm.Take != 0)

            {

                DataSource = operation.PerformTake(DataSource, dm.Take);

            }

           

            

            return dm.RequiresCounts ? Json(new { result = DataSource, count = count }) : Json(DataSource);

        }

 


Screenshot:



Query#: if i apply a search, for example Client 5023, the filter function is not displaying any option


We are able to reproduce your reported problem at our end and currently, we are validating the problem with our source, and we need some more time to validate. So we will update you the further details on 5th Apr 2022. Until then we appreciate your patience.


Regards,

Rajapandi R



RR Rajapandi Ravi Syncfusion Team April 4, 2022 03:45 PM UTC

Hi Rodrigo,


Thanks for your patience


We have considered an improvement feature for this case and logged task for the same as - “provide support get distinct value from server when open the Excel/Checkbox filter”. This feature will be implemented and included in the weekly patch release scheduled to be rolled out by the end of April 2022. We appreciate your patience until then.


You can now track the current status of your request, review the proposed resolution timeline, and contact us for any further inquiries through this link.


Feedback link : https://www.syncfusion.com/feedback/33911/provide-support-get-distinct-value-from-server-when-open-the-excel-checkbox-filter


Regards,

Rajapandi R



RO Rodrigo replied to Rajapandi Ravi April 6, 2022 03:58 AM UTC

Hi Rajapandi, thank you very much for your help.


For the first query ( Query#: When i display the filter, the Status B is missing​) Solution works great with the code provided.


For the second query ( Query#: if i apply a search, for example Client 5023, the filter function is not displaying any option​) Will be waiting for new release.


Thank you very much.



RR Rajapandi Ravi Syncfusion Team April 6, 2022 04:08 AM UTC

Hi Rodrigo,


Query#: When i display the filter, the Status B is missing


We are happy to hear that our provided solution was helpful to resolve the problem at your end.


Query#: if i apply a search, for example Client 5023, the filter function is not displaying any option


Currently, we are working on this query, and we will get back to you once the reported issue “provide support get distinct value from server when open the Excel/Checkbox filter” is fixed and included in our patch release as promised.


Regards,

Rajapandi R



RR Rajapandi Ravi Syncfusion Team April 27, 2022 01:18 PM UTC

Hi Rodrigo,


Sorry for the inconvenienced.


Due to facing complexity of your reported requirement “provide support get distinct value from server when open the Excel/Checkbox filter” we unable to deliver the feature on promised date and currently we are working on this with high priority.


So, we will deliver it in our upcoming patch release which is expected to be roll out in the 4th MAY 2022.


Until that we appreciate your patience.


Regards,

Rajapandi R



RR Rajapandi Ravi Syncfusion Team May 4, 2022 02:06 PM UTC

Hi Rodrigo,


We are glad to announce that our Essential Javascript2 patch release (v20.1.52) has been rolled out successfully and in that release, we have added the fix for the issue - “provide support get distinct value from server when open the Excel/Checkbox filter”. So please update your packages to this version to include this fix.


Feedback Link: https://www.syncfusion.com/feedback/33911/provide-support-get-distinct-value-from-server-when-open-the-excel-checkbox-filter


We thank you for your support and appreciate your patience in waiting for this release. Please get in touch with us if you would require any further assistance.


Regards,

Rajapandi R



JM Jesús Mostajo October 11, 2022 04:24 PM UTC

Hi friends,

I was looking for this issue and I see that v20.1.52 added the fix, but It's not working for me.

The project is .net core 5, I've used v20.1.52 and above until (20.1.61), but I have the same issue:  column filter not showing all available options.

The number of rows in grid is about 13000,

Available items on excel filter:

Captura de Pantalla 2022-10-11 a las 18.18.10.png


If I put "GUAR" appears the hide item:

Captura de Pantalla 2022-10-11 a las 18.19.22.png


Any idea?



RR Rajapandi Ravi Syncfusion Team October 12, 2022 12:54 PM UTC

Hi Jesus,


From your query we could see that you like to display the distinct values in the filter dialog, you can directly return the distinct values from the server.


actionBegin: https://ej2.syncfusion.com/javascript/documentation/api/grid/#actionbegin


 

<script>

    function actionBegin(args) { //actionBegin event of Grid

        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>


By default, the Excel/ Checkbox filter Dialog in the Grid will display the distinct data from the first 1000 records in grid dataSource to optimize the performance. You can also increase the Excel filter choice count by modifying the filterChoiceCount argument value in the actionBegin event when the requestType is ‘filterchoicerequest’ as demonstrated in the below code snippet,


 

function actionBegin(args){

  if(args.requestType == 'filterchoicerequest'){

 

 args.filterChoiceCount = 5000;   // change the filterchoicecount value as you need (the filter check list shown based on this value )

 }

}

 


Kindly use the following code in the server to perform server-side actions with Grid queries.



[HomeController.cs]

public ActionResult UrlDatasource(TestDm dm)

        {

           

            IEnumerable DataSource = orddata.ToList();

            DataOperations operation = new DataOperations();

 

            if (dm.Search != null && dm.Search.Count > 0)

            {

                DataSource = operation.PerformSearching(DataSource, dm.Search);  //Search

            }

            if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting

            {

                DataSource = operation.PerformSorting(DataSource, dm.Sorted);

           }

            if (dm.Where != null && dm.Where.Count > 0) //Filtering

            {

                DataSource = operation.PerformFiltering(DataSource, dm.Where, dm.Where[0].Operator);

            }

            int count = DataSource.Cast<OrdersDetails>().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

            }

            if (dm.Skip != 0)

            {

                DataSource = operation.PerformSkip(DataSource, dm.Skip);   //Paging

            }

            if (dm.Take != 0)

            {

                DataSource = operation.PerformTake(DataSource, dm.Take);

            }

            return dm.RequiresCounts ? Json(new { result = DataSource, count = count }) : Json(DataSource);

        }


Sample: https://www.syncfusion.com/downloads/support/directtrac/general/ze/141605-976392801.zip


Regards,

Rajapandi R


Loader.
Up arrow icon