jQWidgets Forums
jQuery UI Widgets › Forums › General Discussions › Navigation › Tree › Dynamically loaded checkbox items
This topic contains 5 replies, has 2 voices, and was last updated by Ivo Zhulev 8 years, 11 months ago.
-
Author
-
Hello all,
I’m dynamically loading checkbox tree item content via the tree expand event.
I’m using Electron / Node.js and my code is as below:
items.push({ label: thisFileList.path.basename(itemPath), value: fullPath, items: [{value: fullPath, label: ‘Loading…’, checked: checked}], checked: checked });
…
tree.jqxTree(‘addTo’, items, elementAddTo);
The checked state assumes the same state as the expanding parent.
This works fine but the loading node doesn’t need a checkbox.
Is it possible to either remove or disable the checkbox for the loading node when adding content dynamically as above?
Many thanks.
Hi GDL,
Take a look at this demo:
http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxtree/ajaxloading.htm?web
You have access to the element so you cant get it and hide the checkbox(display:none).
Hope this helps you resolve your issue.Best Regards,
IvojQWidgets Team
http://www.jqwidgets.com/Hi Ivo,
Thank you for your response.
So, I have taken your sample and added the css selctor line but this does not work – how should this be structured please?
tree.on(‘expand’, function (event) {
var label = tree.jqxTree(‘getItem’, event.args.element).label;
var $element = $(event.args.element);
var loader = false;
var loaderItem = null;
var children = $element.find(‘ul:first’).children();
$.each(children, function () {
var item = tree.jqxTree(‘getItem’, this);
if (item && item.label == ‘Loading…’) {
loaderItem = item;
loader = true;//line added here
$($element).find(‘.jqx-checkbox-default:first’).css(‘display’, ‘none’);return false
};
});Now solved by changing $($element).find(‘.jqx-checkbox-default:first’).css(‘display’, ‘none’); to $(this).find(‘.jqx-checkbox-default:first’).css(‘display’, ‘none’);
Many thanks.
Although the above works there is a considerable delay before the checkbox is hidden.
Is there a way to specify the checkbox should be hidden when the item is created?
My current code to generate the loading item is:
items.push({ label: thisFileList.path.basename(itemPath), value: fullPath, items: [{value: fullPath, label: ‘Loading…’, checked: checked}], checked: checked });Many thanks.
Hi GDL,
Unfortunately there is no other way of doing that.
Best Regards,
IvojQWidgets Team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.