I've been trying to setup cascading DropDownLists in one of our webapps. The DropDownLists each use a URL data source. Taking the example code from the documentation and updating the appropriate fields (dataSource, fields, cascade queries, etc.) all seem to work fine. But as soon I add "allowFiltering: true", the subsequent DropDownLists do not update when the prerequisite DropDownList value changes. A request gets made to the server and returns the appropriate / corresponding data, however the values available in the connected DropDownLists do not get updated or replaced.
I've created a shell in StackBlitz with as much code as I can provide. I don't know of any publicly accessible URL data sources that take a DataManagerRequest as a parameter, so for now those are just placeholder URLs.
I should note that when the queries for the subsequent DropDownLists get updated, I'm passing a parameter to get the appropriate corresponding data as opposed to using a where clause in the query.
stateObj.query = new ej.data.Query().addParams('CountryId', countryObj.value).take(25);
andcityObj.query = new ej.data.Query().addParams('StateId', stateObj.value).take(25);
instead of
stateObj.query = new ej.data.Query().where('CountryId', 'equal', countryObj.value);
andcityObj.query = new ej.data.Query().where('StateId', 'equal', stateObj.value);
Thanks Ponmani. Just to be clear though, the issue isn't with the query. I've essentially taken the example from the documentation for cascading DropDownLists and
Hi Ponmani,
I don't think you fully understand the issue I'm describing. My issue is not with creating a DropDownList component that uses a URL datasource. I've done that plenty of times without issue. The issue that I'm having is with cascading DropDownLists (so the selection from list A updates the data in list B, and the selection from List B updates the data in List C, etc) and the "allowFiltering" property enabled. The example that you provided in stackblitz is for a single DropDownList with a URL datasource.
Thanks,
Josh
Any follow up on this? You said 2 business days and it's now been a week...
Hi Josh,
We have created a cascading sample with URL datasource based on your requirement . Kindly refer the below code snippet and sample for your references.
[HomeController.cs]
|
public ActionResult UrlDatasource([FromBody]Data dm) { var val = OrdersDetails.GetAllRecords(); var Data = val.ToList(); var cascad = val.ToList();
var count = val.Count(); if (dm.where != null) { Data = (from cust in Data where cust.ShipCountry.ToLower().StartsWith(dm.@where[0].value.ToString()) select cust).Distinct().ToList();
if (Data.Count == 0) { Data = (from cust in cascad where cust.ShipCountry.Equals(dm.@where[0].value.ToString()) select cust).ToList(); } } if (dm.take != 0) Data = Data.Take(dm.take).ToList(); return Json(Data); } |
[Index.ts]
|
// initialize DropDownList component let dropDownListObj: DropDownList = new DropDownList({ // bind the DataManager instance to dataSource property dataSource: new DataManager({ url: 'https://localhost:44334/Home/UrlDatasource', adaptor: new UrlAdaptor(), crossDomain: true, }), // bind the Query instance to query property query: new Query().distinct('ShipCountry'), // map the appropriate columns to fields property fields: { value: 'ShipCountry' }, // set the placeholder to DropDownList input element placeholder: 'Select a country', // sort the resulted items sortOrder: 'Ascending', allowFiltering: true, // set the height of the popup element popupHeight: '200px', change: (args) => { dropDownListObj1.enabled = true; dropDownListObj1.text = null; dropDownListObj1.query = new Query() .select('CustomerID') .where('ShipCountry', 'equal', dropDownListObj.value); dropDownListObj1.dataBind(); }, }); dropDownListObj.appendTo('#customers');
let dropDownListObj1: DropDownList = new DropDownList({ // bind the DataManager instance to dataSource property dataSource: new DataManager({ url: 'https://localhost:44334/Home/UrlDatasource', adaptor: new UrlAdaptor(), crossDomain: true, }), // bind the Query instance to query property query: new Query(), // map the appropriate columns to fields property fields: { value: 'CustomerID' }, // set the placeholder to DropDownList input element placeholder: 'Select a customer', // sort the resulted items sortOrder: 'Ascending', // set the height of the popup element popupHeight: '200px', enabled: false, }); dropDownListObj1.appendTo('#customers1'); |
In the above sample we have binded the datasource as per the selected data in the first dropdown using its change event . So once the value selected , the respective items related to it will be populated in the second dropdown.
Client app : https://stackblitz.com/edit/61scvb-51kyge?file=index.ts
Server App : https://www.syncfusion.com/downloads/support/directtrac/344391/ze/Syncfusion_EJ2_Core_App-503739299
Regards,
Ponmani M
Try adding:
allowFiltering: true,
to the configuration of dropDownListObj1 and see what happens.
Also, I get an access denied error when trying to open the link to the server app download that you provided.
Hi Josh,
Already we have added the allowFiltering property to the Dropdownlist component and attached the workable sample for client and server below for reference. Kindly check with this sample and revert us if you need further assistance.
Client App: https://stackblitz.com/edit/61scvb-51kyge?file=index.ts
Server App: https://www.syncfusion.com/downloads/support/directtrac/general/ze/Syncfusion_EJ2_Core_App-883074012
Regards,
Ponmani M
Can we setup a Teams call? Because this does not work. It works for the initial cascading, like the first time that an item is selected in the parent. But it does not work each time after that, as I said in the initial forum post: " the subsequent DropDownLists do not update when the prerequisite DropDownList value changes".
I made a screen recording showing that yes, it does work the FIRST time. And it works when filtering is NOT enabled. But the nth time, when filtering is enabled, the child dropdowns do not update.
Hi Josh,
Currently we are checking your reported query, we will update further details in 2 business days (April 06, 2022)
Regards,
Ponmani M
Again, any follow up on this? You said 2 business days and it's now been a week...
Also, can this be transferred to somebody within Syncfusion that is more responsive? I created this almost a month ago and we've gotten nowhere.
I am having the same issue on a couple remote data source dropdownlists. child dropdowns data is dependent on the parent dropdownlist selection.
On change of the parent dropdownlist selection, the following is performed in the change event
child.ej2_instances[0].query = new ej.data.Query() .addParams("id", document.getElementById("parent").ej2_instances[0].value);
this only works if filtering is disabled.
In my scenario this is ok, but it is troubling to think that if I need to enable filtering on another control in a similar situation that it won't work.
Vinitha, I received an email about the ticket that was opened below. But as an FYI, see the attached screenshot for what I get when I open the link to the ticket that you provided. It takes me to a BoldDesk login, for which I do not have an account.
Hi Josh,
We hope that you can access the ticket now. please follow up on the ticket for further details.
Vinitha
Was a solution ever found to Josh's issue?
I'm having a very similar issue with my cascading dropdowns not behaving correctly when allowFiltering is enabled. And I'm unable to view the Bolddesk link above.
Thanks!
Hi David Dawkins,
We are pleased to inform you that the fix for the reported issue, "Cascading DropdownList does not get updated data when using a remote data source and allowFiltering is set to true" has been implemented in the weekly patch release version 20.1.57.
We kindly request that you update your NuGet package to the latest version to resolve this issue.
You can find the release notes here:
Release Notes - 20.1.57
For further feedback on this issue, please refer to the link below:
Feedback Link - Cascading DropdownList Issue
If you are using an older version, we recommend upgrading your package to ensure the issue is resolved.
Note :The ticket was previously created under Josh's name, hence you are unable to view the link. Please ignore it.
Regards,
Priyanka K