jQWidgets Forums

jQuery UI Widgets Forums Navigation Tree non-sequential Ids

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

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • non-sequential Ids #64901

    Peter Sloth
    Participant

    Hi

    is there a way to make the getRecordsHierarchy work with non-sequential Ids?
    My data contains records with “holes” due to records being deleted at one point.
    In the code snippet below, the item.id is an ordinal entry in the array, so it of course does not work with non-sequential ids

     $('#jqxTree').on('select', function (event) {
                        var args = event.args;
                        var item = $('#jqxTree').jqxTree('getItem', args.element);
                        var label = item.label;
                        var value = item.value;
                        var type = dataAdapter.records[item.id].type;
                        $("#log").html("<strong>Type:</strong> " + type + ", <strong>Name:</strong> " + label + ", <strong>path:</strong> " + value);
                    });

    thanks

    Peter Sloth

    non-sequential Ids #64902

    Peter Sloth
    Participant

    By looping through the records of the dataadapter I can of course get the record I am looking for 🙂

      for (var i = 0; i < dataAdapter.records.length; i++) {
                            var record = dataAdapter.records[i];
                            if (item.id == record.id) {
                                var type = record.type;
                                $("#log").html("<strong>Type:</strong> " + type + ", <strong>Name:</strong> " + label + ", <strong>path:</strong> " + value);
                                break;
                            }
                        }
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.