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

Excel Filter MaxFilterChoices

Hi, 
we using a URL Adapter and the FilterType.Excel. The property MaxFilterChoices is set to 25. But in the filter menu we only see less than 25 items. I see that the result from the method in the URL adapter returns 25 items (we using the DataManager) but the grid will group it on the column. 

How can I extend our adapter method or grid to get 25 items on each column filter?


.FilterSettings(filter => { filter.FilterType(FilterType.Excel).MaxFilterChoices(25); })

Kind regards,
Carsten

1 Reply

SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team July 19, 2017 12:44 PM UTC

Hi Carsten,  
 
Thanks for contacting Syncfusion Support.  
 
The default behavior will collect the numbers of records mentioned in the MaxFilterChoices from the server-end and it will populate the distinct set of the values in the checkbox list. Hence, 25 records will be reduced to the distinct set of records which is obviously a reduced count in the Excel filter when compare to the MaxFilterChoices value. So, we suggest to return the distinct set of records to the client end. Refer to the following code example. 
 
We are selecting the required filtering column in the ActionBegin event of the Grid and same has been retrieved from the server-end as a distinct set of records. 
 
@(Html.EJ().Grid<object>("FlatGrid") 
         .Datasource(ds => ds.URL("/Home/DataSource1").Adaptor(AdaptorType.UrlAdaptor)) 
         .AllowFiltering() 
         .AllowPaging() 
         .ClientSideEvents(e=>e.ActionBegin("onActionBegin")) 
         .FilterSettings(f=>f.FilterType(FilterType.Excel).MaxFilterChoices(25)) 
                    .Columns(col => 
                            { 
                                col.Field("OrderID").HeaderText("OrderID").Add(); 
                                col.Field("CustomerID").HeaderText("Customer ID").Width(100).Add(); 
                                col.Field("Freight").Width(120).Add(); 
                                col.Field("ShipName").Width(100).Add(); 
                            }) 
) 
 
<script> 
    function onActionBegin(args) { 
        if (args.requestType == "filterchoicerequest") { 
            //selects only the filtering column 
            //which prevents the serialization errror. 
            args.query.select(args.filterModel.fName); 
        } 
    } 
 
</script> 
 
       public ActionResult DataSource1(Syncfusion.JavaScript.DataManager dm) 
        { 
            IEnumerable datasource = OrderRepository.GetAllRecords(); 
            DataOperations operation = new DataOperations(); 
            if (dm.Where != null)//for filtering 
                datasource = operation.PerformWhereFilter(datasource, dm.Where, dm.Where[0].Condition);  
            //selects only the required columns 
            if (dm.Select != null) 
            { 
                datasource = operation.PerformSelect(datasource, dm.Select); 
                /* 
                 convert dataSource to the distinct set of the records based on the dm.Select value 
                 */ 
            } 
            int count = datasource.AsQueryable().Count(); 
            if (dm.Skip >= 0)//for paging 
                datasource = operation.PerformSkip(datasource, dm.Skip); 
            if (dm.Take > 0)//for paging 
                datasource = operation.PerformTake(datasource, dm.Take); 
            return Json(new { result = datasource, count = count }); 
        } 
 
 
Regards,  
Seeni Sakthi Kumar S. 


Loader.
Up arrow icon