jQuery EasyUI最新试用版免费下载>
在本教程中,您将学习如何在可编辑的数据网格中包含一个运算列。计算列一般含有一个或多个其他列计算的值。
首先创建可编辑的数据网格。在这里我们创建了一些可编辑的列,'listprice'、'amount'和'unitcost'列被定义为numberbox编辑类型。运算列是'unitcost'字段,将是listprice乘以amount列的结果。
Item ID | List Price | Amount | Unit Cost | Attribute | Status |
---|
当用户点击一行时,我们开始一个编辑操作。
var lastIndex; $('#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); } }) } });
购买jQuery EasyUI最新正版授权!详情请"咨询在线客服"
葡萄城经典UI产品新年大促,惊喜折扣礼品送不停!
本站文章除注明转载外,均为本站原创或翻译