zoukankan      html  css  js  c++  java
  • datagrid 的2个问题

    1)对datagrid的某个栏位值使用下拉方式   

     <th data-options="field:'UserId',100,
                            formatter: unitformatter,
                            editor:{
                                type:'combobox',
                                options:{
                                    valueField:'UserId',
                                    textField:'userName',
                                    url:'../../manager.ashx?act=GetMgr&plantNo='+plantNo,
                                    required:true,
                                    onSelect: function (record) {                                
                                        $('#dg').datagrid('getRows')[editIndex]['userName']=record.userName;
                                    }
                                }   
                            }               
                            ">主管名字</th>
    

     这个是对该栏位使用ajax的方式得到值来填充。

    但是这次使用的比较简单,我们的选项是固定的(本来想放到数据库中,感觉没有必要了,先直接放到页面上可选算了)

    结果还发现赋值很难找到诀窍,网上找到的东西都是语焉不详的,花了我2个小时时间,最终搞定结果如下。

    <th data-options="field:'Reason',80,align:'left'
                            ,editor:{
                                type:'combobox',
                                options:{
                                    valueField:'text',
                                    textField:'text',
                                    data: Reasons,
                                    required:true                               
                                }   
                            }           
                            ">超領原因</th>
    
    ---Javascript定义全局变量Reasons;
    var Reasons; Reasons = $.parseJSON('[{ "text": "作業損耗" }, { "text": "機器異常" }, { "text": "其它" }]');

    2)对datagrid的某个栏位值设定为必输栏位

    上面有对combobox 设定必输,但是我需要对几个"text" 设定必输,网上的资料也是不详细,很多人说直接加" options:{required:true}“就可以了,

    可是加了也是不起作用的,都准备放到endEdit里面进行处理了,最后终于灵光一闪,发现了一个问题,修改Type就可以了。

    <th data-options="field:'PartNo',160,align:'left',editor:{type:'validatebox',options:{required:true}}">料號</th>
    

     万事大吉了,数字类型的栏位可以直接加限制就OK了。

                       <th data-options="field:'Qty',40,align:'left',editor:{type:'numberbox',options:{required:true}}">數量</th>
    

      

     

  • 相关阅读:
    vue 使用echarts 柱状图使用图片显示
    Devexpress分组小计
    小写转大写
    预览打印
    LINQ
    结束任务管理器进程
    游标
    查看死锁
    sql 分页
    压缩解压缩传输的数据
  • 原文地址:https://www.cnblogs.com/wonder223/p/9940102.html
Copyright © 2011-2022 走看看