EasyUI Forum
April 18, 2024, 11:46:17 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: appendRow - how to add new record to "datagrid" ?  (Read 2392 times)
paule32
Newbie
*
Posts: 12


View Profile Email
« on: January 15, 2022, 01:25:29 AM »

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...

Code:
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
}
});
}

Logged
paule32
Newbie
*
Posts: 12


View Profile Email
« Reply #1 on: January 15, 2022, 03:38:30 PM »

this Question forms to my (later) Bug Report, today.
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #2 on: January 16, 2022, 07:40:06 PM »

Please call this code instead.
Code:
$("#dg" + dg).datagrid('appendRow',{
    [t1]: s1,
    [t2]: s2,
    [t3]: s3,
    [t4]: s4
});
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!