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.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • Dynamically loaded checkbox items #86810

    GDL
    Participant

    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.

    Dynamically loaded checkbox items #86832

    Ivo Zhulev
    Participant

    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,
    Ivo

    jQWidgets Team
    http://www.jqwidgets.com/

    Dynamically loaded checkbox items #86837

    GDL
    Participant

    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
    };
    });

    Dynamically loaded checkbox items #86838

    GDL
    Participant

    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.

    Dynamically loaded checkbox items #86839

    GDL
    Participant

    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.

    Dynamically loaded checkbox items #86855

    Ivo Zhulev
    Participant

    Hi GDL,

    Unfortunately there is no other way of doing that.

    Best Regards,
    Ivo

    jQWidgets Team
    http://www.jqwidgets.com/

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.