jQuery UI Widgets Forums TreeGrid TreeGrid Dynamic loading, getting data null error

This topic contains 1 reply, has 2 voices, and was last updated by  Peter Stoev 8 years, 7 months ago.

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

  • formanite77
    Participant

    I am trying to use virtual mode of the treegrid. When i click the tree node, i get following error. On each tree node, click i want to get the data from server. I don’t want to provide url because we have our own SDK to make the request and then parse the response
    Uncaught ReferenceError: data is not defined

    here is my code.

    $(“#jqxTreeGrid”).jqxTreeGrid(
    {
    width: 600,
    pageable: true,
    altRows: true,
    virtualModeCreateRecords: function(expandedRecord, done)
    {
    // expandedRecord is equal to null when the function is initially called, because there is still no record to be expanded.

    // prepare the data
    var source =
    {
    dataType: “json”,
    dataFields: [
    { name: ‘id’, type: ‘number’ },
    { name: ‘parentId’, type: ‘number’ },
    { name: ‘name’, type: ‘string’ },
    { name: ‘createdOn’, type: ‘string’ },
    { name: ‘lastModifiedOn’, type: ‘string’ },
    { name: ‘createdBy’, type: ‘string’ },
    { name: ‘organization’, type: ‘string’},
    { name: ‘icon’, type: ‘string’ },
    ],
    localData: expandedRecord === null ? self.contentList : self.getChildNodes(expandedRecord.id, function(data){
    return data;
    }),
    id: ‘id’
    }
    var dataAdapter = new $.jqx.dataAdapter(source, {

    formatData: function (data) {
    if (expandedRecord == null) {
    data.$filter = “(ReportsTo eq null)”
    }
    else {
    data.$filter = “(ReportsTo eq ” + expandedRecord.EmployeeID + “)”
    }
    return self.contentList;
    },
    loadComplete: function () {
    done(dataAdapter.records);
    },
    beforeLoadComplete: function (records) {
    self.getChildNodes(records.id, function(data){
    return data;
    });
    }
    });
    dataAdapter.dataBind();
    },
    virtualModeRecordCreating: function(record)
    {
    if (record.parentId) {
    // by setting the record’s leaf member to true, you will define the record as a leaf node.
    record.leaf = true;
    }
    },
    columns: [
    {
    text: ”, dataField: ”, width: 50,
    /*renderer: function (text, align, height) {
    return “<div style=’margin: 5px; margin-top: 7px;’></div>”;
    }*/
    },
    { text: ‘Title’, dataField: ‘name’, width: “20%” },
    { text: ‘Added By’, dataField: ‘createdBy’, width: “20%” },
    { text: ‘Organization’, dataField: ‘organization’, width: “20%” },
    { text: ‘Added On’, dataField: ‘createdOn’, width: “20%” },
    { text: ‘Modified On’, dataField: ‘lastModifiedOn’, width: “20%”}
    ]
    });
    and getChildNodes is the method which makes the call and get the data, it is ajax request. Before it returns i get the error Uncaught ReferenceError: data is not defined.

    Any response will be appreciated.


    Peter Stoev
    Keymaster

    Hi formanite77,

    data is undefined I believe is not an error raised by our widget. I would suggest you to either check your getChildNodes function implementation and debug it or provide jsfiddle.net sample which demonstrates an issue with our widget.

    Best Regards,
    Peter Stoev

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

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

You must be logged in to reply to this topic.