• editrules


    editrules
        editrules是用来设置一些可用于可编辑列的colModel的额外属性的。大多数的时候是用来在提交到服务器之前验证用户的输入合法性的。比如editrules:{edithidden:true, required:true....}。
        可选的属性包括:
        edithidden:只在Form Editing模式下有效,设置为true,就可以让隐藏字段也可以修改。
        required:设置编辑的时候是否可以为空(是否是必须的)。
        number:设置为true,如果输入值不是数字或者为空,则会报错。
        integer:
        minValue:
        maxValue:
        email:
        url:检查是不是合法的URL地址。
        date:
        time:
        custom:设置为true,则会通过一个自定义的js函数来验证。函数定义在custom_func中。
        custom_func:传递给函数的值一个是需要验证value,另一个是定义在colModel中的name属性值。函数必须返回一个数组,一个是验证的结果,true或者false,另外一个是验证错误时候的提示字符串。形如[false,”Please enter valid value”]这样。
        自定义验证的例子:

        <script>
            function mypricecheck(value, colname) {
            if (value < 0 && value >20) 
               return [false,"Please enter value between 0 and 20"];
            else 
               return [true,""];
            }

            jQuery("#grid_id").jqGrid({
            ...
               colModel: [ 
                  ... 
                  {name:'price', ..., editrules:{custom:true, custom_func:mypricecheck....}, editable:true },
                  ...
               ]
            ...
            });
        </script>    <         function mypricecheck(value, colname) {         if (value < 0 && value >20)             return [false,"Please enter value between 0 and 20"];         else             return [true,""];         }          jQuery("#grid_id").jqGrid({         ...            colModel: [                ...                {name:'price', ..., editrules:{custom:true, custom_func:mypricecheck....}, editable:true },               ...            ]         ...         });      // >

    formoptions(只在Form Editing方式下有效),他的主要作用是用来重新排序Form中的编辑元素,同时可以在编辑元素前或者编辑元素后增加一些信息(比如,一些提示信息,或者一个红色的*表示必须要填写等等)。
        可选的属性如下:
        elmprefix:字符串值,如果设置了,则会在编辑框之后出现一些内容(可能是HTML的内容)
        elmsuffix:字符串值,如果设置了,则会在编辑框之前出现一些内容(可能是HTML的内容)
        label:字符串值,如果设置了,则这个值会替换掉colNames中的值出现作为该编辑框的标签显示
        rowpos:数字值,决定元素行在Form中的位置(相对于文本标签again with the text-label)
        colpos:数字值,决定元素列在Form中的位置(相对于标签again with the label)
        两个编辑框可以有相同的rowpos值,但是colpos值不同,这会把这两个编辑框放到Form的同一行中。
        特别注意:如果设置了rowpos以及colpos的值,强烈推荐为所有的其他编辑元素都设置这些值。

  • 相关阅读:
    阿里云API网关(1)服务网关的产品概述
    Spring Security 入门(1-1)Spring Security是什么?
    Spring Security入门(2-1)Spring Security
    gradle入门(1-5)创建并运行Web应用
    gradle入门(1-4)多项目构建实战
    gradle入门(1-3)使用gradle开发一个发布版本
    gradle入门(1-2)gradle的依赖管理
    gradle入门(1-1)gradle的概念和使用
    BZOJ1925: [Sdoi2010]地精部落(dp)
    BZOJ1812: [Ioi2005]riv(树形dp)
  • 原文地址:https://www.cnblogs.com/kuailewangzi1212/p/3529486.html
Copyright © 2020-2023  润新知