EasyUI Forum
May 07, 2024, 12:57:05 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Loading New Combo Data doesn't Clear Selected Option....  (Read 13492 times)
2plus2
Jr. Member
**
Posts: 75


View Profile
« on: November 05, 2014, 04:18:12 PM »

We have a combo box that is loaded with data dynamically based on the user selected. We pass a JSON object to the combobox to build the dropdown instead of pulling the data from an AJAX call directly:

Code:
$('#' + trans[x] + 'InitiatorThreshold').combobox({ data: data[trans[x]].Thresholds });

If an option is selected from a previous "state", that selection is *not* cleared when the combo box is loaded with new data.

The reason it's an issue, is just after loading the new data the validType event fires:

Code:
validType: 'exists["#' + trans[x] + 'InitiatorThreshold"]'

and it fails validation with a selected option that should not persist after a reload of the dropdown options.

Is this the intended behaviour of the drop down? Currently, we are setting the value of the drop down to index "0" prior to new data being loaded in order for it always to pass validation after rebuild.
« Last Edit: November 06, 2014, 09:18:20 AM by 2plus2 » Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 on: November 05, 2014, 05:16:11 PM »

Calling 'loadData' to load new data does not clear the existing value. If you want to clear the previous value, please call 'clear' method before calling 'loadData' method, or recreate the combobox again.
Code:
$('#cc').combobox('clear').combobox('loadData', newdata);
//or
$('#cc').combobox({data:newdata});
Logged
2plus2
Jr. Member
**
Posts: 75


View Profile
« Reply #2 on: November 05, 2014, 11:38:15 PM »

Thanks - but that's not it. Added it and it's still behaving as if there is an event to fire after the JSON data is loaded.

I've sent a more detailed email to support requesting help. It's very consistent. Works as expected until the validation fails, then every time we reload the drop down options with a new JSON object something runs the previous reload command and rebuilds the drop down with data we don't want / require.

« Last Edit: November 05, 2014, 11:40:52 PM by 2plus2 » Logged
2plus2
Jr. Member
**
Posts: 75


View Profile
« Reply #3 on: November 06, 2014, 09:16:22 AM »

Just for completeness, the root cause of the issue was:

We make a reload call based on certain conditions, and that sets the URL for the combobox. On load of the new JSON data for the drop down, once the URL is set the combobox makes another URL call for data using the cached URL value.

e.g.
Code:
$('#' + type + 'InitiatorThreshold').combobox('reload', '/controls/ajaxBankUsers.aspx?a=getThresholdListPlus&r=' + $('#Account').combobox('getValue') + '&i=' + $('#' + type + 'ThresholdId').val() + '&q=' + missingID);

So every time we load JSON data we need to set the URL back to null:

Code:
$('#' + trans[x] + 'InitiatorThreshold').combobox({ data: data[trans[x]].Thresholds, url: null });

(Thanks to your email support team. :-)

P.S. Not sure why both execute. I would think that when I load a JSON object for the data, that the URL wouldn't execute. But now that we know, we can avoid it.
« Last Edit: November 06, 2014, 09:18:48 AM by 2plus2 » Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!