zoukankan      html  css  js  c++  java
  • 动态修改datagrid中的numberbox的最大值和最小值

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

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

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

    <table id="dg"  style="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',150,hidden:true">规则ID</th>
                                            <th data-options="field:'createTime',150,hidden:true">规则创建时间</th>
                                            <th data-options="field:'prodSrvId',150,hidden:true">服务ID</th>
                                            <th data-options="field:'srvName',150">服务名称</th>
                                            <th data-options="field:'srvCode',150">服务编号</th>
                                            <th data-options="field:'providerName',150">所属厂商</th>
                                            <th data-options="field:'srvTypeDesc',108">服务类型</th>
                                            <th data-options="field:'rate',100,formatter:function(value,row){if(value!=null&&value!=0) {return value+'%';}}">分摊比例</th>
                                            <th data-options="field:'ruleType',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',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
    				});
    		    }		
    		}
    

      

  • 相关阅读:
    mysql truncate
    蠕虫复制
    mysql 一对多,多对多
    php实现文件下载
    JetBrains PhpStorm 整个项目中查找一个词语
    vim
    程序员减少代码BUG的7种方法,拒绝编程5分钟,查代码2小时!
    创建你的第一个Composer/Packagist包
    Elasticsearch
    Laravel 实践之路: 数据库迁移与数据填充
  • 原文地址:https://www.cnblogs.com/toSeeMyDream/p/6955631.html
Copyright © 2011-2022 走看看