easyui numberbox输入框 编辑不可编辑的切换

背景:申请单里需要选费用类型,费用类型有的有子明细项,有个合计项

     当有子明细项的时候,合计项的值是通过弹出的子明细项价格的总和(设置为可编辑没问题,因为点击出来弹框,编辑不了)

     没有子明细项的时候,合计项直接手填

    当费用类型没有选择的时候,合计项设置为不可编辑状态

首先:

找到需要编辑的numberbox

$aplgrid:easyui 的grid 容器

iExpenseClaimItemIndex:行索引

AmountWithTax: 指定列

var edNumberbox = $aplgrid.datagrid('getEditor', { index: iExpenseClaimItemIndex, field: 'AmountWithTax' });

可编辑不可编辑需要分别设置

可编辑的设置

$(edNumberbox .target).numberbox('enable', true);

不可编辑的设置:

$(edNumberbox .target).numberbox('disable', true);

注:当numberbox 设置为不可编辑的时候,触发不了点击事件

  有明细项是点击出来弹框的效果

所以 选择费用类型的时候 就需要将numberbox 设置为可编辑的状态

  点击numberbox 的时候,如果没有选择费用明细 设置为不可编辑的状态

原文地址:https://www.cnblogs.com/yigexiaojiangshi/p/9722221.html