Closed cracki closed 4 years ago
I know it may be a little late for you, but I implemented this in my fork: https://github.com/crazy4chrissi/combo-tree
Hi, I Want to change the Json value dynamically.But it displayed old value only. Json value not updated dynamically.
This issue and the whole JSON is about the initial data of the tree. "Initial" implies it is not dynamical ;)
So what you want to do is select a value using JS? By id? Of course you can just trigger click()
on the respective element to select/unselect an item. Sure, a predefined function for that would be handy.
Yes, I am done using id. Function invoke ajax call and pass data comboTree.But data not rendered. Initial data only displayed.dynamic data not worked.
I know it may be a little late for you, but I implemented this in my fork: https://github.com/crazy4chrissi/combo-tree
would it be possible to add an extra attribute selected=true|false to each json "leaf"? this way the plugin can set initial selection. I think that without this is not so much usefull
@blacktek What is the difference between what you propose and the preselect
attribute I added in my fork? Just add it to any leaf you want initially selected.
@blacktek What is the difference between what you propose and the
preselect
attribute I added in my fork? Just add it to any leaf you want initially selected.
sorry I didn't notice it; I manually edited the source to add this functionality :) I added a "disabled" property too in order to have nodes that are not selectable. Thank you!
one thing I made differently was adding at line 116 this code:
this._selectedItem = { id: sourceItem.id, title: sourceItem.title };
this._selectedItems.push(this._selectedItem);
I didn't do the trigger('click') in the constructor; the proposed solution should be more cpu effective.
Guys, i did make changes and got setting value to work. Just add these functions along with other prototype functions and use it.
`
// Set Values
// *****************************
ComboTree.prototype.setValues = function (data) {
if (data !== null &&
data !== undefined &&
typeof data !== "string" &&
typeof data !== "number" &&
typeof data !== "function") {
if (data.length > 0) {
for (var k = 0; k < data.length; k++) {
this.manageValues(data[k]);
}
}
}
};
ComboTree.prototype.manageValues = function(sourceItem) {
var isThereSubs = sourceItem.hasOwnProperty("subs");
if (isThereSubs) {
var li = $('#' + this.comboTreeId + 'Wrapper li.ComboTreeItemParent');
li.find('span.comboTreeItemTitle[data-id=' + sourceItem.id + ']').trigger("click");
this.manageValues(sourceItem.subs);
} else {
$('#' + this.comboTreeId + 'Wrapper span.comboTreeItemTitle[data-id=' + sourceItem.id + ']').trigger("click");
}
};
` Hope it helps. Enjoy! :)
Usage:
comboTree.setValues(objArr);
Hi all,
You can use setSelection
method of new version.
Thanks...
Hello, I'll be out of the office until the 29th of December.
I'll reply on my return.
Kind Regards, TT
Hi all, I am new to combo tree. how do i implement setSelection method Could you please help on this
Uncaught TypeError: setSelection is not a function.
This error is coming while setting value using setSelection.
how we can Initialize Value? like this: http://www.jeasyui.com/demo/main/index.php?plugin=ComboTree&theme=default&dir=ltr&pitem=
Thank You