EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: officecode on January 09, 2019, 10:59:03 PM



Title: The value in the onCellEdit event is always undefined
Post by: officecode on January 09, 2019, 10:59:03 PM
I am trying 'cellediting' and want to implement the navigation effects of up, down, left and right in the onCellEdit event.
The problem is that the value here is always undefined.
I have found similar problems in the forum, but the sample files can't be opened. Can you help me with an example or sample code? Thank you!


Title: Re: The value in the onCellEdit event is always undefined
Post by: stworthy on January 10, 2019, 02:13:18 AM
The 'value' parameter value is only available when calling 'editCell' method and pass the 'value' parameter.
Code:
$('#dg').datagrid('editCell', {
    index: 1,
    field: 'productid',
    value: 'value1'
})


Title: Re: The value in the onCellEdit event is always undefined
Post by: officecode on January 10, 2019, 06:32:49 AM
I still don't quite understand. Even if the editCell method is executed, the value in the onCellEdit event is still undefined.
For example, if I press the Enter key in the cell, how can I get the char code:

Code:
$('#dg').datagrid({
url:'test.php',
        //...
onCellEdit:function(index,field,value){
              console.log(value)       //The initialized value from the pressed char code on keyboard
        }
}).datagrid('enableCellEditing')


Title: Re: The value in the onCellEdit event is always undefined
Post by: stworthy on January 10, 2019, 06:31:58 PM
Please look at this example http://code.reloado.com/ocoviy4/edit#preview

Click on the button to edit a cell with a updated value and you will get the 'value' parameter. Click or press ENTER on the datagrid cells to edit a cell, the 'value' parameter lost but you can get the current cell value by this code:
Code:
var fieldValue = $(this).datagrid('getRows')[index][field];
console.log(fieldValue);


Title: Re: The value in the onCellEdit event is always undefined
Post by: officecode on January 10, 2019, 07:34:26 PM
Ok, I see. I originally thought that the key code of the input can be obtained here by the value parameter. It seems that I still have to deal with the input keydown, I hope to press the Enter key to automatically navigate to other cells.
thank you for your help!