EasyUI Forum
June 26, 2024, 06:21:58 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: How can I capture the changed cell value when I click anywhere outside the cell  (Read 7467 times)
wolfnbasti
Newbie
*
Posts: 16


View Profile
« on: May 22, 2014, 08:31:03 PM »

I use the following to create a editable datagrid:
            var attributeDefs;
            var resources;
            var resourceDef;
            var attributeValues;
            var attributeIds;

            $(function() {
                $.ajax({
                    url: '../rest/...../attributes',
                    type: "GET",
                }).done(function(data) {
                    attributeDefs = data.attributeDefs;
                    resourceDef = data.resourceDef;
                    resources = data.resources;
                    attributeValues = data.attributes.values;
                    attributeIds = data.attributes.ids;
                    var frozenColumns = [];
                    frozenColumns.push({
                        field: '0',
                        title: 'Name',
                        align: 'left',
                        width: 100,
                        resizable: true,
                  editable: true,
                        fixed: false,
                    });
                    var columns = [];
                    columns.push({
                        field: '0',
                        title: 'Name',
                        align: 'left',
                        width: 100,
                        resizable: true,
                  editable: true,
                        fixed: false
                    });
               for (var i = 0; i < attributeDefs.length; i++) {
                        columns.push({
                            field: (i + 1).toString(),
                            title: attributeDefs.name,
                            align: 'left',
                            width: 100,
                            resizable: true,
                            fixed: false,
                     editable: true,
                     editor: 'text',
                        });
                    }
                    var rows = [];
                    for (var i = 0; i < resources.length; i++) {
                        var attributeObject = {'0' : resources.name};
                        for (var j = 0; j < attributeDefs.length; j++) {
                            attributeObject[(j + 1).toString()] = attributeValues[j];
                        }
                        rows.push(attributeObject);
                    }
                    $('#ClientData').edatagrid({
                        columns: [columns],
                        data: rows,
                        editable: true,
                        fitColumns: true,
                        singleSelect: true,
                        nowrap: true,
                        striped: true,
         onDblClickCell: function(row, field, value) {

                        }
                    });
                });
            });

<table id="ClientData" title="Attributes" class="edatagrid" style="width:1200px;height:600px" toolbar="#toolbar" fitColumns="true" editable="true" ></table>


I need to capture the value of the changed cell after the onDblClickCell line as soon as the user clicks anywhere else in the grid or out of it. Any ideas how this might be done?

Thanks.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: May 23, 2014, 12:03:32 AM »

You can bind any events to the editor when a row goes into edit mode.
Code:
$('#tt').edatagrid({
onEdit:function(index,row){
var editors = $(this).edatagrid('getEditors',index);
$(editors[0].target).bind('change',function(){
//...
})
}
});
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!