EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: sky-t on December 17, 2019, 11:30:18 PM



Title: Update datagrid row in function
Post by: sky-t 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
                    }
                });
            }
        }

    }


Title: Re: Update datagrid row in function
Post by: stworthy 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
})


Title: Re: Update datagrid row in function
Post by: sky-t on December 18, 2019, 05:34:07 AM
This is awesome!!!!

Thank you stworthy!!!!