jQuery UI Widgets › Forums › TreeGrid › add chid dynamically in tree grid
Tagged: add, addrow, child, dynamically, jqxTreeGrid, row, tree grid
This topic contains 4 replies, has 2 voices, and was last updated by guru 10 years, 9 months ago.
-
Author
-
hi,
i want to add child row to a parent row dynamically when i click add buttonHello guru,
Please check out the demo Inline Row. In it, if you select a node (e.g. Europe) and click the + (Add) button in the toolbar, a child row will be added to the selected one (Europe).
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/i can try that one but it will ad parent node only or add new row i can attached my code here
var source =
{
dataType: “json”,
dataFields: [
{name: ‘fpcId’, type: ‘number’},
{name: ‘programId’, type: ‘number’},
{name: “children”, type: “array”},
{name: ‘program’, type: ‘string’},
{name: ‘programid’, type: ‘string’},
{name: ‘Ad Duration’, type: ‘string’},
{name: ‘Caption’, type: ‘string’},
{name: ‘Commercial’, type: ‘string’},
{name: ‘Remarks’, type: ‘string’},
{name: ‘Brk Duration’, type: ‘string’},
{name: ‘Start Time’, type: ‘date’},
{name: ‘End Time’, type: ‘date’},
{name: ‘Ad Start Time’, type: ‘date’},
{name: ‘Ad End Time’, type: ‘date’},
{name: ‘Release Order No’, type: ‘date’},
{name: ‘Ro Start Time’, type: ‘date’},
{name: ‘Bi Line No’, type: ‘date’},
{name: ‘Ro Time’, type: ‘date’},
{name: ‘Spot Pos’, type: ‘date’},
{name: ‘CAT’, type: ‘date’},
{name: ‘Spot Id’, type: ‘date’},
{name: ‘Spot Note’, type: ‘date’},
{name: ‘Amount’, type: ‘date’},
{name: ‘Alias’, type: ‘date’},
{name: ‘Node Key’, type: ‘date’},
{name: ‘Pattern Id’, type: ‘date’},
{name: ‘Bill No’, type: ‘date’},
{name: ‘Fis Year’, type: ‘date’},
{name: ‘Tape Id’, type: ‘date’},
{name: ‘Bill Proce’, type: ‘date’}],
hierarchy:
{
root: “children”
},
id: ‘fpcId’,
localdata: data,
addRow: function(rowID, rowData, position, parentID, commit) {
// synchronize with the server – send insert command
// call commit with parameter true if the synchronization with the server is successful
// and with parameter false if the synchronization failed.
// you can pass additional argument to the commit callback which represents the new ID if it is generated from a DB.
commit(true);
newRowID = rowID;
}};
for (var i = 0; i < bucketPrgId.length; i++) {
if (bucketPrgId[i] !== undefined) {
var finalrows = $(“#finalizationGrid”).jqxTreeGrid(‘getRows’);
for (var j = 0; j < finalrows.length; j++) {
var finalPrgId = $(“#finalizationGrid”).jqxTreeGrid(‘getKey’, finalrows[j]);
alert(bucketPrgId[i] + “===” + finalPrgId);
if (bucketPrgId[i] === finalPrgId) {
var rec = finalrows[j].records;
for (var k = 0; k < rec.length; k++) {
var childKey = $(“#finalizationGrid”).jqxTreeGrid(‘getKey’, rec[k]);// $(“#finalizationGrid”).jqxTreeGrid(‘expandRow’, childKey);
$(“#finalizationGrid”).jqxTreeGrid(‘addRow’, null, {}, ‘first’, childKey);
// $(“#finalizationGrid”).jqxTreeGrid(‘clearSelection’);
// $(“#finalizationGrid”).jqxTreeGrid(‘selectRow’, childKey);
// edit the new row.
// $(“#finalizationGrid”).jqxTreeGrid(‘beginRowEdit’, childKey);
// $(“#finalizationGrid”).jqxTreeGrid(‘endRowEdit’, childKey, false);
//}
}
}
}
}in the above code all values are passed correctly but it will not worked
Hi guru,
The suggested demo does exactly as is your requirement – on the click of a button, it adds a new sub-row (child) to a selected parent row, e.g. a new country to Europe. Please check the demo out and review its source code.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/i can use json data ,its hirachy only children it have any problem to add record to child
-
AuthorPosts
You must be logged in to reply to this topic.