EasyUI Forum
May 17, 2024, 05:54:20 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 cell value from edatagrid?  (Read 8077 times)
wolfnbasti
Newbie
*
Posts: 16


View Profile
« on: April 16, 2014, 09:33:21 PM »

I need to capture the cell value from an instance of edatagrid so I can save it via javascript to a server side REST process. How can I capture the new row values and the edited existing row values into a var?

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


View Profile Email
« Reply #1 on: April 17, 2014, 06:21:06 AM »

Please call 'getRows' method to get a specified row.
Code:
var index = ...  // the row index
var row = $('#dg').datagrid('getRows')[index];
console.log(row);  // the row data
Logged
wolfnbasti
Newbie
*
Posts: 16


View Profile
« Reply #2 on: April 21, 2014, 03:56:29 PM »

This is what I did to get the value I needed when adding a new row:

$('#dg').edatagrid('endEdit',newRowIndex);
rowAdd = JSON.parse(JSON.stringify($('#dg').edatagrid('getRows',newRowIndex)));
var newValue =  rowAdd[newRowIndex].columnNameWhatever;

However, when trying something similar for editing an existing row I can't seem to capture the edited row index, let alone any of the changed values. It almost seems that when I click my save feature, which for testing purposes just generates an alert pop-up, it isn't recognizing that I'm ending the edit.

When I first double click a row to edit, I probably I need to capture the row number at that time, and when I'm done editing signal the end edit process and capture the values. Do you have any ideas?

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


View Profile Email
« Reply #3 on: April 21, 2014, 05:31:12 PM »

If you are using edatagrid plugin to create a basic crud application, you don't care about how to save or edit a row, what you need to do is to set the 'url','saveUrl','updateUrl' and 'destroyUrl' properties.
Code:
$('#tt').edatagrid({
    url: ...,
    saveUrl: ...,
    updateUrl: ...,
    destroyUrl: ...
});
Logged
wolfnbasti
Newbie
*
Posts: 16


View Profile
« Reply #4 on: April 22, 2014, 06:04:25 AM »

I can't use that process because we are using javascript to talk to a server side REST process. So, I need to capture the edited cell index and the edited values and then pass the changes to our established REST process.

I think if I can capture the cell index as soon as editing starts, I'm guessing when a cell is double-clicked I can then capture the changes made to the cell.

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


View Profile Email
« Reply #5 on: April 22, 2014, 07:39:17 AM »

When double click a row to start editing, the 'onEdit' event fires. You can use it to get the current editing row index.
Code:
$('#dg').edatagrid({
  onEdit: function(index,row){
    console.log(index);
  }
});
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!