Hello,
how the topic say's: "How to add new record to "datagrid" ?
I have this little function (code below), I have static code, to
init. fill the datagrid (columns, data properties are set, and
then datagrid is shown without error's).
Then I open a dialog, press save button, that calls saveUser.
The "alert" box in the middle is shown, and display the right
message/value from the form's input value.
But future more at code, it would be add a empty record.
So, the question is: "How to add data to the new record ?"
For assistance, and helping hands, are welcome.
Thank You ver much...
Here is the code, that I have so far away...
function saveUser(dg)
{
let row2, idx2, dg2;
let frm2 = "";
$("#fm"+dg).form('submit',{
iframe: false,
success: function(result)
{
row2 = $('#dg'+dg).datagrid('getSelected');
idx2 = $('#dg'+dg).datagrid('getRowIndex',row2);
let t1 = 'firstnamedg'+dg;
let t2 = 'lastnamedg' +dg;
let t3 = 'phonedg' +dg;
let t4 = 'emaildg' +dg;
let s1 = $('#'+t1).textbox('getValue').replace(/ $/g,"");
let s2 = $('#'+t2).textbox('getValue').replace(/ $/g,"");
let s3 = $('#'+t3).textbox('getValue').replace(/ $/g,"");
let s4 = $('#'+t4).textbox('getValue').replace(/ $/g,"");
alert(t1 + '\n' + s1);
$('#dg'+dg).datagrid('appendRow',{
t1: s1, t2: s2,
t3: s3, t4: s4
});
$('#dlg'+dg).dialog('close'); // close the dialog
}
});
}