EasyUI Forum
November 04, 2025, 12:59:37 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Question about combotree::onChange() event  (Read 20031 times)
mzeddd
Full Member
***
Posts: 223



View Profile
« on: October 02, 2015, 03:36:00 AM »

Hi,

I have two combotrees in the way when I (de)select values on 1st combotree 2nd combotree changes its content (I change URL parameter).

I do this in the following way:
Code:
$('#test2').combotree({url:'test.php?test='+test});

I also have onChange event on my 2nd combotree to disable/enable button if something is selected or not.
It works fine when I select/deselect items on combotree, but it does not work when I change URL to load new data.
When I change URL and load new data I lost all what was selected previousely => value is changed (set to '') => onChange needs to be called.

Can I use any other events or do I need to add extra checks and function calls in my code to make it work?

Thanks,
//V
Logged
jarry
Administrator
Hero Member
*****
Posts: 2300


View Profile Email
« Reply #1 on: October 02, 2015, 06:49:47 AM »

If you would like to reload the combotree data, please call 'reload' method instead.
Code:
$('#test2').combotree('reload', 'test.php?test='+test);
Logged
mzeddd
Full Member
***
Posts: 223



View Profile
« Reply #2 on: October 02, 2015, 07:16:08 AM »

I see one thing with 'reload':

For example I have some data in my combotree, and several items already checked (I have checkboxes).
If I reload data and new data extands existing data then it looks really great. What was selected - remains selected and I don't need to select it again as I do when I change URL.

But, if I reload data and new data does not include records that I have initially selected then old records remain selected.
Also, as old data is not available in combotree I see "ID"s for old records.

Can EasyUI self check this situation and deselect unavailable items?

In this case onChange event will work as I expect without extra magic from my side Smiley

Logged
mzeddd
Full Member
***
Posts: 223



View Profile
« Reply #3 on: October 02, 2015, 07:25:22 AM »

Small addition to my prev. post.

In case if I load tree like this (with multiple:true,onlyLeafCheck:false)

Root1[X]
--Item1[X]
Root2[ ]
--Item2[ ]

And select "Item1" I get "Root1" selected automatically - as expected, good

I 'reload' data which extands my existing dataset and also includes a number of elements in "Root1"
When reload is done all new items in "Root1" get selected, but I did not select them - no good
Logged
jarry
Administrator
Hero Member
*****
Posts: 2300


View Profile Email
« Reply #4 on: October 02, 2015, 08:31:36 AM »

When loaded data successfully, you can filter your selected values. If some values do not exist in the tree data, you can remove them and then call 'setValues' method to re-set the combotree values.
Code:
var ct = $('#ct');
ct.combotree({
cascadeCheck: true,
multiple: true,
onLoadSuccess: function(){
var values = ct.combotree('getValues');
var newvalues = ...
ct.combotree('setValues',newvalues);
}
})
Logged
mzeddd
Full Member
***
Posts: 223



View Profile
« Reply #5 on: October 05, 2015, 03:34:16 AM »

I think it should be done automatically without any extra code from users side as it needs to be done for many combotree's elements.
Logged
jarry
Administrator
Hero Member
*****
Posts: 2300


View Profile Email
« Reply #6 on: October 05, 2015, 04:04:00 AM »

No, once the user selects values, the combotree can't remove any selected items. The user must do that by himself regarding his business logic.
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!