动态修改datagrid中的numberbox的最大值和最小值

注意datagrid使用的触发函数是:

onBeginEdit,只有在这个触发条件下,editor才真正初始化完成,不然没法动态修改numberbox中的最大最小值。

示例代码:(注意这一块:onBeginEdit:changeNumberMax)

<table id="dg"  style="width:960px;height:auto"
data-options="
singleSelect: true,
url: '<%=request.getContextPath() %>/settlementRule/relatedServices?prodId=${productDto.prodId }',
method:'get',
onLoadSuccess:checkData,
onBeginEdit:changeNumberMax
">
<thead>
<tr>
<th data-options="field:'id',width:150,hidden:true">规则ID</th>
<th data-options="field:'createTime',width:150,hidden:true">规则创建时间</th>
<th data-options="field:'prodSrvId',width:150,hidden:true">服务ID</th>
<th data-options="field:'srvName',width:150">服务名称</th>
<th data-options="field:'srvCode',width:150">服务编号</th>
<th data-options="field:'providerName',width:150">所属厂商</th>
<th data-options="field:'srvTypeDesc',width:108">服务类型</th>
<th data-options="field:'rate',width:100,formatter:function(value,row){if(value!=null&&value!=0) {return value+'%';}}">分摊比例</th>
<th data-options="field:'ruleType',width:150,formatter:function(value,row){if(value==${FIXED_ACCOUNT_SETTLEMENT}) {return '固定金额结算'} else if(value==${PROPORTION_SETTLEMENT}) { return '按比例结算'} },
editor:{type:'combobox',options:{url: '<%=request.getContextPath() %>/settlementRule/getSettlementRuleTypeEnums',valueField:'enumEntryValue',textField:'enumEntryLabel',
method:'get',editable:'true',panelHeight: 'auto',required:'true',editable:false}}">结算类型</th>
<th data-options="field:'val',width:150,formatter:function(value,row){if(value!=null){if(row.ruleType==${PROPORTION_SETTLEMENT}) {return value+'%';} else if(row.ruleType==${FIXED_ACCOUNT_SETTLEMENT}) {return value;}}},editor:{type:'numberbox',options:{required:'true',min:0,precision:2}}">结算规则</th>
</tr>
</thead>
</table>

相应的触发函数:

function  changeNumberMax(rowIndex,rowData)  {
var ruleType=rowData.ruleType;
if(ruleType==0) {
var sharePercent=rowData.rate;
var ed = $('#dg').datagrid('getEditor', {index:rowIndex,field:'val'});
$(ed.target).numberbox({
max: ${productDto.prodPrice }*sharePercent/100,
precision: 2,
min:0
});
}
}

  

上一篇:Redis中hash表中的field的value自增可以用hincrby


下一篇:bzoj1015 星球大战