jQuery MiniUI

 找回密码
 立即注册
查看: 2404|回复: 1
打印 上一主题 下一主题

datarid 行编辑时,根据单下拉框的值,控制单元格可编辑 [复制链接]

Rank: 3Rank: 3

跳转到指定楼层
楼主
发表于 2016-8-20 15:05:18 |只看该作者 |倒序浏览
如何所示,我要根据有害生物的值,来判断是虫害的话,虫口数量单元格允许编辑,病斑数单元格不可编辑
现在我的问题是,我页面加载时,我直接设置虫口数量跟病斑数单元格不可编辑,通过js来控制其允许编辑的时候报错,在   wpmcInput.setEnabled(true);提示Cannot read property 'setEnabled' of undefined,应该怎么表示呢

   <div field="PestId" width="100"  required="true" type="comboboxcolumn" headeralign="center" align="center">
                    林业有害生物
                    <input property="editor" id="PestName" name="PestName" class="mini-combobox" style="width: 100%;" textfield="DictionaryName" valuefield="DictionaryId" emptytext="林业有害生物"
                        url="../../AjaxService/MES_Ajax.aspx?method=GetPestType" showNullItem="true" />
                </div>
                <div field="WormNum" vtype="int" width="80" headeralign="center" align="center">
                    虫口数量   
                          <input property="editor"  Enabled="false"   name="WormNum" id="WormNum"  class="mini-textbox" style="width: 100%;" />
                </div>
                <div field="LesionTrunkNum" vtype="int" width="90" headeralign="center" align="center">
                    树干病斑数   
                          <input property="editor"   Enabled="false"    id="LesionTrunkNum" name="LesionTrunkNum" class="mini-textbox" style="width: 100%;" />
                </div>
                <div field="LeafDiseasesId"    type="comboboxcolumn" autoshowpopup="true" width="120" headeralign="center" align="center">
                    叶部病害比例                        
                       <input property="editor" class="mini-combobox"  Enabled="false"  id="LeafDiseasesId" name="LeafDiseasesId" style="width: 100%;" textfield="DictionaryName" valuefield="DictionaryId" emptytext="叶部病害比例"
                           url="../../AjaxService/MES_Ajax.aspx?method=GetProportionOfLeafDiseases" />
                </div>



function Pestchanged(e) {
            var PestId = mini.getbyName("PestName");
            console.log(PestId);
            $.ajax({
                url: "../../AjaxService/MES_Ajax.aspx?method=GetPestNameType&DictionaryId=" + PestId.value,
                cache: false,
                success: function (text) {
                    var o = mini.decode(text);
                    var PestNameType = o[0].PestType;
                    //alert(PestNameType);
                    if (PestNameType == '0') {//虫害
                        var wpmcInput = mini.getbyName("WormNum");
                        wpmcInput.setEnabled(true);
                        alert(2);
                        var wpmcInput = mini.getbyName("LeafDiseasesId");
                        wpmcInput.setEnabled(true);
                        var wpmcInput = mini.getbyName("LesionTrunkNum");
                        wpmcInput.setEnabled(false);
                        var wpmcInput = mini.getbyName("BudsNum");
                        wpmcInput.setEnabled(false);
                    }
                    else if (PestNameType == '1') {
                        var wpmcInput = mini.getbyName("LesionTrunkNum");
                        wpmcInput.setEnabled(true);
                        var wpmcInput = mini.getbyName("BudsNum");
                        wpmcInput.setEnabled(true);
                        var wpmcInput = mini.getbyName("WormNum");
                        wpmcInput.setEnabled(false);
                        var wpmcInput = mini.getbyName("LeafDiseasesId");
                        wpmcInput.setEnabled(false);
                    }

                }
            });
        }


附件: 你需要登录才可以下载或查看附件。没有帐号?立即注册

Rank: 8Rank: 8

沙发
发表于 2016-8-22 09:24:17 |只看该作者
http://www.miniui.com/demo/#src=datagrid/editable.html
请参考可控编辑的示例,在oncellbeginedit事件内处理

Archiver|普加软件

GMT+8, 2024-9-29 04:18 , Processed in 1.035260 second(s), 10 queries .

Powered by Discuz! X2

© 2001-2011 Comsenz Inc.

回顶部