EasyUI Forum
May 14, 2024, 04:02:32 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: Update datagrid row in function  (Read 4600 times)
sky-t
Full Member
***
Posts: 145


View Profile
« on: December 17, 2019, 11:30:18 PM »

Hi there,

i want to update datagrid rows by calling a function with the field and value.
How can i use the field variable to update the row?

Code:
    function update_contact_row(field, value) {
        var rows = $('#table_contacts_contacts').datagrid('getRows');
        for (var i=0; i < rows.length; i++) {
            if (rows[i].id == "{{contacts_id}}") {
                $('#table_contacts_contacts').datagrid('updateRow', {
                    index: i,
                    row: {
                        $field: value
                    }
                });
            }
        }

    }
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: December 18, 2019, 01:08:56 AM »

Please refer to this code.
Code:
var row = {};
row[field] = value;
$('#table_contacts_contacts').datagrid('updateRow', {
index: i,
row: row
})
Logged
sky-t
Full Member
***
Posts: 145


View Profile
« Reply #2 on: December 18, 2019, 05:34:07 AM »

This is awesome!!!!

Thank you stworthy!!!!
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!