EasyUI Forum
November 05, 2025, 12:51:48 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: calcualte numberbox-values in a datagrid  (Read 9470 times)
jaimi
Full Member
***
Posts: 121


View Profile
« on: October 07, 2016, 02:43:17 AM »

In your tutorial give the following sample:
Code:
$('#tt').datagrid({
    onClickRow:function(rowIndex){
        if (lastIndex != rowIndex){
            $(this).datagrid('endEdit', lastIndex);
            $(this).datagrid('beginEdit', rowIndex);
        }
        lastIndex = rowIndex;
    },
    onBeginEdit:function(rowIndex){
        var editors = $('#tt').datagrid('getEditors', rowIndex);
        var n1 = $(editors[0].target);
        var n2 = $(editors[1].target);
        var n3 = $(editors[2].target);
        n1.add(n2).numberbox({
            onChange:function(){
                var cost = n1.numberbox('getValue')*n2.numberbox('getValue');
                n3.numberbox('setValue',cost);
            }
        })
    }
});

As I understand you walk through the array of all editors within the row an assign them to the names n1,n2,...
If I don't want / need all existing editors for my calculation I would have the risk of corruption of the calculation if the order of fields changes.
Is it possible to address the field-editor by name or similar?
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: October 07, 2016, 08:06:00 PM »

You can call 'getEditor' method with 'index' and 'field' parameter values to get the specified editor on datagrid row.
Code:
var ed = $(this).datagrid('getEditor', {index: index, field: 'listprice'});
var val = $(ed.target).numberbox('getValue');
console.log(val);
Logged
jaimi
Full Member
***
Posts: 121


View Profile
« Reply #2 on: October 08, 2016, 01:05:55 AM »

How would I put this in the onBeginEdit function?
Which function would be appropiate?
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!