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.
Unfortunately, activation email could not send to your email. Please try again.

How to change the dataSource for the checkbox list in excel filtering

 

 

You can change the datasource/query for the checkbox list in excel filter using ActionBegin event of Grid. The following code example shows how to change the datasource in excel Filtering of Grid.

  1. Render the Grid control.

JS

MVC

ASP.NET

 2. You can change the dataSource/query in the actionBegin event. In the below we have modified the excel filter query by adding a take query. Here checkbox list datasource show depends upon take query value.

 JS

 

Figure 1: Excel filter with query modified.

 

 

Article ID: Published Date: Last Revised Date: Platform: Control:
7580 03/22/2017 03/22/2017 JavaScript ejGrid
Did you find this information helpful?
Comments
Hugo Arevalo Sep 06, 2017

Is it possible to change the datasource for the checkboxlist??

Reply
Saravanan Arunachalam [Syncfusion] Sep 07, 2017

Hi Hugo,

Thanks for contacting Syncfusion’s support.

In this knowledge base document, we have queried the dataSource and based on it we have rendered the checkbox list.

And we can achieved your requirement by changing the dataSource in the filterModel which you can get from the actionBegin event with requesType “filterchoicerequest”.  Please refer to the below code example.

        $(function () {

            $("#Grid").ejGrid({

                . . .

                actionBegin: "begin"

            });

        });

        function begin(args) {

            //In here we have assigned the empty data to the ShipCountry field       

            if(args.requestType == "filterchoicerequest" && args.filterModel.fName == "ShipCountry")

                args.filterModel._dataSource = [];

        }

   

 

 

For your convenience we have created a simple sample in the jsplayground.

http://jsplayground.syncfusion.com/v4bw2jh0

Regards,

Saravanan A.

Hugo Arevalo Sep 21, 2017

I tried your sample and I can succesfully change the datasource for only one filter, however when applying the filter the options are gone and I'm unable to load them again.

Thanks,

Hugo A.

Reply
Venkatesh Ayothi Raman [Syncfusion] Sep 23, 2017

Hi Hugo,

 

Thanks for the update,

 

We have changed data source based on field name while clicking the filter icon and we were unable to reproduced the reported issue at our end as well as we have prepared a sample for your convenience which can be  referred from following link,

Sample: http://jsplayground.syncfusion.com/iz0fhgzd

 

In this sample, we have changed the excel filter data source for ShipCountry column in actionBegin event. If you still face the same issue, then could you please provide following information,

1)      Share the code example of action begin event.

2)      Scenario for replication procedure.

3)      You have mentioned about filter options. Please share the more details of it.

4)      A sample if possible or modified the given sample as issue reproducible.

 

 

Regards,

Venkatesh Ayothiraman.

Hugo Arevalo Sep 25, 2017

When I apply another filter the information gets lost. I put this on the begin event:

if(args.requestType == "filterchoicerequest" && args.filterModel.fName == "ShipCountry") {

              var countryDataSource = [{ShipCountry : "Germany"}, {ShipCountry : "Brazil"}];

                 args.filterModel._dataSource = countryDataSource;

            }  

Is there any way for it to work?

Thanks,
Hugo

Reply
Venkatesh Ayothi Raman [Syncfusion] Sep 26, 2017

Hi Hugo, 

 

Thanks for the update.

 

By default, the excel filter render the checkbox list items based on the records in the Grid’s dataSource initially and the checkbox list item will render based on the filtered data after applying the filtering for any one of the column which is default behavior and it is behave similar to the filtering in Microsoft excel. So, overriding the above mentioned behavior is not feasible. 

 

Regards,

Venkatesh Ayothiraman.

Add Comment
You must log in to leave a comment

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.