EasyUI Forum
June 28, 2024, 07:09:56 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: The value in the onCellEdit event is always undefined  (Read 4371 times)
officecode
Jr. Member
**
Posts: 69


View Profile Email
« 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!
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 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'
})
Logged
officecode
Jr. Member
**
Posts: 69


View Profile Email
« Reply #2 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')
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 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);
Logged
officecode
Jr. Member
**
Posts: 69


View Profile Email
« Reply #4 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!
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!