Hello Syncfusion Team,
I want to change the datasource of my checkbox filter to a custom datasource (true and false). I tried the approach of this thread https://www.syncfusion.com/kb/11339/how-to-change-the-data-source-for-checkbox-filter-popup-in-grid but I think it didn't work for me because I am using an async data source on my grid.
In my code when the dataStateChange event is called, just like in the normal string filters I am ignoring the request when it is a checkbox filter:
The outcome is that there is just a loading spinner in the filter popup. There is also no error in the console.
Am I doing something wrong or is there simply no way for me to set a custom data source to the checkbox filter when I am using an async data source?
You can find more of my code and grid in the attachments.
Kind Regards, Peter
Attachment: grid_13254819.zip
|
actionBegin(args) {
if (
args.requestType == 'filterSearchBegin' ||
args.requestType == 'filterchoicerequest'
) {
args.filterModel.options.dataSource = [
{ ShipCity: true },
{ ShipCity: false },
];
}
}
public dataStateChange(state: DataStateChangeEventArgs): void {
if (
state.action &&
(state.action.requestType == 'filterchoicerequest' ||
state.action.requestType == 'filterSearchBegin' ||
state.action.requestType == 'stringfilterrequest')
) {
if (state.action.filterModel.options.field == 'ShipCity') {
return state.dataSource(state.action.filterModel.options.dataSource);
} else {
this.service.getData(state).subscribe((e) => state.dataSource(e));
}
} else {
this.service.execute(state);
}
}
|
Hi Syncfusion Team,
Thanks for your reply. Your approach is working but only when no other filter is active. Whenever I filter another column and then want to filter with my true/false filter column then the filter shows no entries and when i delete the other filters the true/false filter works again.
Here is my Code:
Here is a screenshot of the filter:
Do you have an idea why this happens?
Kind Regards, Peter
Hi Syncfusion-Team,
If I understood you right you are telling me that there is no way that I can filter a column and then filter another column with a custom filter?
So in my grid I can't filter the column "Label" and then filter the column "Active/Inactive" where i customized the filter entries with "active" and "inactive", because there would be no entries in the checkbox filter?
Kind Regards,
Peter
Hi Peter,
Thanks for your update.
Query: If I understood you right you are telling me that there is no way
that I can filter a column and then filter another column with a custom filter?
Yes, the checkbox items are shown based on the previous filter predicates. If
you provide custom dataSource on particular Checkbox filter, then it will not
be shown when other columns are filtered.
|
public dataStateChange(state: DataStateChangeEventArgs): void { if ( state.action && (state.action.requestType == 'filterchoicerequest' || state.action.requestType == 'filterSearchBegin' || state.action.requestType == 'stringfilterrequest') ) { this.service.getData(state).subscribe((e) => state.dataSource(e)); // bind array of object to state.dataSource method } else { this.service.execute(state); } }
|
Regards,
Rajapandiyan S
Hello Syncfusion-Team,
we need to use a custom data source in the grid filter, because for example in this grid we are using an enum in the column "Field type":
And we can't just display 0, 1, 2, ... in the checkbox filter because no one would know what that value stands for. We have to display the text values behind the enum, for example 0 => Text; 1 => Number; and so on.
The problem that I have faced with the above way is that when you filter another column first and then filter the column with the custom data source filter, there will be no values displayed.
Is there any way to make this work?
Kind Regards,
Peter
Hi Peter,
Thanks for contacting Syncfusion support.
By default, the EJ2 Grid column only supports number, string, date, dateTime, Boolean, checkbox type values, and it does not support Enum & array type values. Refer to the below documentation.
columnType: https://ej2.syncfusion.com/documentation/api/grid/columnType/
So, the Grid does not support any data actions like Filtering, Sorting, Editing, Searching, Grouping, etc., on the Enum type of column. This is the behavior of EJ2 Grid.
Regards,
Rajapandiyan S
Hi Syncfusion-Team,
Sorry but I cannot imagine that it is not possible to assign a custom data source to the checkbox filter. Maybe I didn't express it very clearly. For example in this grid we have to be able to first filter the column "Name" and then filter the column "Field type" where we would have to assign a custom data source where we put following entries: "Text", "Number", "Checkbox", "Multiselect", "Dropdown" and "Date/Time".
Is this really not possible with your grid?
Kind Regards,
Peter
Hi Peter,
Thanks for your update.
We have created a new ticket under your account for the reported query. We suggest you follow up with that ticket for further updates.
Regards,
Rajapandiyan S