jQWidgets Forums

jQuery UI Widgets Forums Navigation Tree element not expanding after children added

This topic contains 1 reply, has 1 voice, and was last updated by  joepacelli 10 years, 10 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author

  • joepacelli
    Participant

    I followed one of your examples of dynamically loading mt jqxTree. My 3 is 2 and 3 levels deep
    At the top level the user has parent items to select from. When they expand one I see the Loading… child element.
    Once the records are loaded to the parent item is not expanded, it’s closed, but the image is showing the expanded image.
    I have to click the image to turn it to collapse image, and then reclick it to actually expand my item
    All my data loaded fine.

    $('#FromLocation').on('expand', function (event) {
                var label = $('#FromLocation').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 = $('#FromLocation').jqxTree('getItem', this);
                    if (item && item.label == 'Loading...') {
                        loaderItem = item;
                        loader = true;
                        return false
                    };
                });
                if (loader) {
                    var parent = loaderItem.parentId.substring(0,1);
                    TransportLocationSource.data = { OrgNbr: $("#OrgNbr").val(), level: parent, parentId: loaderItem.value, localityCd: window.localityCd };
                    TransportLocationSource.url = '@Url.Action("GetChildLocationsJsonResult", "JobDetail")';
                    TransportLocationAdapter = new $.jqx.dataAdapter(TransportLocationSource, {
                        loadComplete: function(data) {
                            var records = TransportLocationAdapter.getRecordsHierarchy('id', 'parentid', 'items', [{ name: 'text', map: 'label' }]);
                            $('#FromLocation').jqxTree('addTo', records, $element[0]);
                            $('#FromLocation').jqxTree('removeItem', loaderItem.element);
                        }
                       
                    });
                    TransportLocationAdapter.dataBind();
                }
            });

    joepacelli
    Participant

    Actually resolved my issue.
    I have 2 dropdownlist. They both have identical data. One is my FromLocation. The other is my ToLocation
    My main focus was on the FromLocation and getting it to work.
    It turned out I needed to change the parent_id’s so they were unique in both tree’s.
    They were conflicting

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

You must be logged in to reply to this topic.