EasyUI Forum
April 28, 2024, 09:30:02 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Find Datagrid Record and Update  (Read 9957 times)
BinaryCode
Newbie
*
Posts: 37


View Profile
« on: June 30, 2015, 04:21:58 PM »

Hello,

I have datagrid like this:

Code:
<table class="easyui-datagrid" style="width:400px;height:250px"
        data-options="url:'datagrid_data.json',fitColumns:true,singleSelect:true">
    <thead>
        <tr>
            <th data-options="field:'id',width:100">ID</th>
            <th data-options="field:'name',width:100">Name</th>
            <th data-options="field:'price',width:100,align:'right'">Price</th>
        </tr>
    </thead>
</table>

Is possible find datagrid recording by id, and update record onthefly without reload again?

TIA
« Last Edit: June 30, 2015, 04:29:42 PM by BinaryCode » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: July 01, 2015, 01:42:06 AM »

You have to find the record by yourself. After that, call 'getRowIndex' method to get the row index and then call 'updateRow' method to update that row.

Code:
var dg = $('#dg');
var row = null;
var rows = dg.datagrid('getRows');
for(var i=0,len=rows.length; i<len; i++){
    if (rows[i]['itemid'] == 'EST-11'){
        row = rows[i];
        break;
    }
}
if (row){
    var index = dg.datagrid('getRowIndex', row);
    dg.datagrid('updateRow', {
        index: index,
        row: {
            attr1: 'updated Attribute'
        }
    })
}
Logged
BinaryCode
Newbie
*
Posts: 37


View Profile
« Reply #2 on: July 01, 2015, 03:51:31 PM »

Hi stworthy,

Very help me,

TIA,
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!