Search code examples
javascriptdatagridjquery-easyui

easyui datagrid insertrow get input value


I mean I want to insert a new row in datagrid to use insertrow method.

but the rows parameter is fixed ,i want to get the new values when i click save button

code belows.

$("#insertRow").click(function(){

var row = $('#dg').datagrid('getSelected');
if (row){
    var index = $('#dg').datagrid('getRowIndex', row);
} else {
    index = 0;
}
$('#dg').datagrid('insertRow', {
    index: index,
    row:{long:row.long} //I mean this place must be the value i typed ,like row.long
});

$('#dg').datagrid('selectRow',index);
$('#dg').datagrid('beginEdit',index);   });

Solution

  • you can try like this if you want to set the blank value

    $('#dg').datagrid('insertRow', {
    index: index,
    row:{long:''}
    });
    

    and row:{long:'long1'} to set the value to the field ** if this is not helping, please provide your datagrid code and please more explicit of your code row:{long:row.long}