EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: mapner on December 13, 2017, 05:08:51 PM



Title: Datagrid updateRow Error
Post by: mapner on December 13, 2017, 05:08:51 PM
Hi,

I got the next code:

Code:
<table id="g-customers" class="easyui-datagrid" style="width:750px;height:165px"  url="myurl" singleSelect="true">  
<thead> 
<th field="Id" hidden="true">ID</th> 
<th field="Name" width="80">Name</th> 
</tr> 
</thead> 
</table>

...
...
...

function Update(){
var row = $("#g-customers").datagrid("getSelected");
var rowIndex = $("#g-customers").datagrid("getRowIndex", row);    
$('#g-customers').datagrid('updateRow',rowIndex,{Id: "60",Name:"John"});
}

In the line   $('#g-vtd').datagrid('updateRow',rowIndex,{Id: "60",Name:"John"});
I get the error:

Uncaught TypeError: Cannot read property 'Id' of undefined

thanks for advance



Title: Re: Datagrid updateRow Error
Post by: jarry on December 14, 2017, 07:11:58 AM
Please try this code instead.
Code:
$('#g-customers').datagrid('updateRow', {
  index: rowIndex,
  row: {Id: "60",Name:"John"}
});


Title: Re: Datagrid updateRow Error
Post by: mapner on December 15, 2017, 06:30:15 PM
Oh! My bad!

Thanks!