...
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
}
... |
// 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
}
} |
<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);
}
|
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.
Issue 1: When i display the filter, the Status B is missing:
But, if i check the function, the Status B is also missing:
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.
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
Hi Rajapandi, looking forward to the update. Thank you very much.
Regards,
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
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
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.
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.
Rajapandi R
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
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
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:
If I put "GUAR" appears the hide item:
Any idea?
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.
{
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