jQWidgets Forums
jQuery UI Widgets › Forums › TreeGrid › Virtual mode / AJAX. Response contain two level of data
Tagged: tree grid
This topic contains 1 reply, has 2 voices, and was last updated by Peter Stoev 7 years, 11 months ago.
-
Author
-
Hi.
I’m trying use the TreeGrid in virtual mode with ajax.
When widget sent first initiate request, response contain 2 level data.
Example:[{ 'id': 1, 'name':'test 1', 'parent_id':null }, { 'id': 2, 'name':'test 2', 'parent_id':null }, { 'id': 3, 'name':'test 1.1', 'parent_id':1 }]
When I expand row ‘test 1’, widget send request to server, but I can’t understand why?
Is it possible send request to server only when I expand row ‘test 1.1’?
My code:var source = { dataType : "json", dataFields: [ {name: 'id', type: 'number'}, {name: 'parent_id', type: 'number'}, {name: 'name', type: 'string'} ], id : 'id', hierarchy : { keyDataField : {name: 'id'}, parentDataField: {name: 'parent_id'} }, root : 'data', url : 'data.php' }; $('#grid').jqxTreeGrid({ .... virtualModeCreateRecords : function (expandedRecord, done) { var dataAdapter = new $.jqx.dataAdapter(source, { formatData : function (data) { if (expandedRecord != null) { data.parent = expandedRecord.id; } return data; }, loadComplete: function () { done(dataAdapter.getRecordsHierarchy('id', 'parent_id', 'records')); }, loadError : function (xhr, status, error) { done(false); throw new Error("Error: " + error.toString()); } }); dataAdapter.dataBind(); }, virtualModeRecordCreating: function (record) { record.leaf = false; }, columns : [ { text : 'name', dataField : 'name' } ] }));
Hi Slava Laptev,
In this mode, the function is called when you expand a tree row. How you load your data then is not something the TreeGrid cares of. It depends on the developer’s own implementation.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.