jqGrid colModel 参数(来自中文手册)

jqGrid colModel 参数


ColModel 是jqGrid里最重要的一个属性,设置表格列的属性。

属性 数据类型 备注 默认值
align string left, center, right. left
classes string 设置列的css。多个class之间用空格分隔,如:'class1 class2' 。表格默认的css属性是ui-ellipsis empty string
datefmt string ”/”, ”-”, and ”.”都是有效的日期分隔符。y,Y,yyyy 年YY, yy 月m,mm for monthsd,dd 日. ISO Date (Y-m-d)
defval string 查询字段的默认值
editable boolean 单元格是否可编辑 false
editoptions array 编辑的一系列选项。{name:’__department_id’,index:’__department_id’,200,editable:true,edittype:’select’,editoptions: {dataUrl:”/jqGrid/admin/deplistforstu.action”}},这个是演示动态从服务器端获取数据。 empty
editrules array 编辑的规则{name:’age’,index:’age’, 90,editable:true,editrules: {edithidden:true,required:true,number:true,minValue:10,maxValue:100}},设定 年龄的最大值为100,最小值为10,而且为数字类型,并且为必输字段。 empty
edittype string 可以编辑的类型。可选值:text, textarea, select, checkbox, password, button, image and file. text
fixed boolean 列宽度是否要固定不可变 false
formoptions array 对于form进行编辑时的属性设置 empty
formatoptions array 对某些列进行格式化的设置 none
formatter mixed 对列进行格式化时设置的函数名或者类型 {name:’sex’,index:’sex’, align:’center’,60,editable:true,edittype:’select’,editoptions: {value:’0:待定;1:男;2:女’},formatter:function(cellvalue, options, rowObject){
var temp = “<img src=’/jqGrid/jquery-ui-1.7.2.custom/css/img/”
if(cellvalue==1){
temp = temp +”user-white.png”;
} else if(cellvalue==2){
temp = temp +”user-white-female.png”;
} else {
temp = temp + “user-silhouette.png”;
}
temp = temp + “‘ border=’0 ′ />”
return temp;
}},// 返回性别的图标。
none
hidedlg boolean 是否显示或者隐藏此列 false
hidden boolean 在初始化表格时是否要隐藏此列 false
index string 索引。其和后台交互的参数为sidx empty
jsonmap string 定义了返回的json数据映射 none
key boolean 当从服务器端返回的数据中没有id时,将此作为唯一rowid使用只有一个列可以做这项设置。如果设置多于一个,那么只选取第一个,其他被忽略 false
label string 如果colNames为空则用此值来作为列的显示名称,如果都没有设置则使用name 值 none
name string 表格列的名称,所有关键字,保留字都不能作为名称使用包括subgrid, cb and rn. Required
resizable boolean 是否可以被resizable true
search boolean 在搜索模式下,定义此列是否可以作为搜索列 true
searchoptions array 设置搜索参数 empty
sortable boolean 是否可排序 true
sorttype string 用在当datatype为local时,定义搜索列的类型,可选值:int/integer - 对integer排序float/number/currency - 排序数字date - 排序日期text - 排序文本 text
stype string 定义搜索元素的类型 text
surl string 搜索数据时的url empty
width number 默认列的宽度,只能是象素值,不能是百分比 150
xmlmap string 定义当前列跟返回的xml数据之间的映射关系 none
unformat function ‘unformat’单元格值 null

以下是详细说明:

1.0 colModel 要呈现字段的属性设置
1.1 align 定义数据相对单元格的对齐方式.string left
1.2 datefmt 日期格式, string Y-m-d
1.3 editable 定义字段是否可编辑 boolean false
1.4 defval 搜索字段的默认值,(只用于自定义搜索) string empty
1.5 edittype 该字段控件类型(text, textarea, select, checkbox, password, button, image , file) string text
1.6 surl 只有在自定义搜索和edittype属性为select和描述的url得到select 的element% string empty
1.7 editoptions 针对edittype配置的控件类型的属性设置 array empty array
1.7.1 value 依据edittype,配置属性%(详见: editoptions的value配置)mixed none
1.7.2 dataUrl 这个属性只适用与edittype属性为select (指定select的数据源edittype:"select",editoptions:{dataUrl:'test.txt', defaultValue:'Intime'}) string empty
1.7.3 dataInit 当控件被创建时仅触发1次 function null
1.7.4 dataEvents 给当前控件追加事件处理% array empty array
1.7.5 defaultValue 默认值(可以是函数返回值) mixed none
1.7.6 其他 可设置控件的任何有效属性editoptions:{size:10,maxlength:8}mixed none
1.8 editrules 设置编辑字段的控件的规则 array empty array
1.8.1 edithidden 该字段隐藏时, 此属性可以控制是否可编辑 boolean false
1.8.2 required 是否验证空数据 boolean false
1.8.3 number 是否验证数字 boolean false
1.8.4 integer 是否验证整数 boolean false
1.8.5 minValue 验证最小值 number(integer) empty
1.8.6 maxValue 验证最大值 number(integer) empty
1.8.7 email 是否验证email boolean false
1.8.8 url 是否验证是有效的网址 boolean false
1.8.9 date 是否验证日期 boolean false
1.8.10 time 是否验证时间 boolean false
    如果此字段不是必填,如果填了才验证是否是email 那么应该配置 email:true, required:false
1.9 formoptions 设置该字段相对表单中的相关设置 array empty array
1.9.1 elmprefix 如果设置,则会在控件前面出现该设置 string empty
1.9.2 elmsuffix 如果设置,则会在控件后面出现该设置 string empty
1.9.3 label 如果设置,则会替换colNames设置的名称 string empty
1.9.4 rowpos 设置该字段所在行的位置,从1开始计数 number empty
1.9.5 colpos 设置该字段所在列的位置,从1开始计数 number empty
1.10 formatoptions 设置特定列的格式,覆盖语言文件的默认值 array empty array
1.11 formatter 指定formatoptions设置格式的类型 mixed none
1.11.1 integer 当formatter指定为此属性时, formatoptions可以设置以下属性.
1.11.1.1 thousandsSeparator 每千位分隔符 string empty
1.11.1.2 defaulValue 在没有数据的情况下的默认值 string empty
1.11.2 number 当formatter指定为此属性时, formatoptions可以设置以下属性.
1.11.2.1 decimalSeparator 小数位分隔符 string empty
1.11.2.2 thousandsSeparator 每千位分隔符 string empty
1.11.2.3 decimalPlaces 小数位数 string empty
1.11.2.4 defaulValue 在没有数据的情况下的默认值 string empty
1.11.3 currency 当formatter指定为此属性时, formatoptions可以设置以下属性.
1.11.3.1 decimalSeparator 小数位分隔符 string empty
1.11.3.2 thousandsSeparator 每千位分隔符 string empty
1.11.3.3 decimalPlaces 小数位数 string empty
1.11.3.4 defaulValue 在没有数据的情况下的默认值 string empty
1.11.3.5 prefix 在数据前面添加的文本比如货币符号”$” string empty
1.11.3.6 suffix 在数据后面添加的文本比如货币符号”$” string empty
1.11.4 date 当formatter指定为此属性时, formatoptions可以设置以下属性.
1.11.4.1 srcformat 原格式 string empty
1.11.4.2 newformat 新的输出格式 string empty
1.11.5 email 当formatter指定为 email类型,直接使这个email加href string empty
1.11.6 link 当formatter指定为此属性时, formatoptions可以设置以下属性.
1.11.6.1 target 默认为empty如果设置,则创建一个以单元格的值和target属性的链接string empty
1.11.7 showlink 当formatter指定为此属性时, formatoptions可以设置以下属性.
1.11.7.1 baseLinkUrl 链接. string empty
1.11.7.2 showAction 附加值,在baseLinkUrl后面 . string empty
1.11.7.3 addParam 额外参数. string empty
1.11.7.4 target 如果设置,增加1条附加属性. string empty
1.11.7.5 idName 是第1个参数,之后由showAction补充,默认情况下,这是id string empty
1.11.8 checkbox 当formatter指定为此属性时, formatoptions可以设置以下属性.
1.11.8.1 disabled 默认true禁止改变状态,如果设置为false是可以改变的 boolean
1.11.9 select 当edittype ,formatter指定为此属性时, editoptions:{value:"1:One;2:Two"}值是1,2显示的则是one,two string empty
    colModel:[{name:'myname', edittype:'select', formatter:'select', formatoptions:{baseLinkUrl:'myrul.php', addParam: '&action=edit', idName:'myid'}, ...}
1.12 unformat 可以为formatter指定自定义格式的方法 function null
1.13 hidedlg 如果设置为true在显示/隐藏字段功能中,该字段将不会出现% boolean false
1.14 hidden 该字段是否隐藏 boolean false
1.15 index 排序时, sidx的参数 string empty
1.16 jsonmap 定义json映射这个字段时的json字符串 string empty
1.17 xmlmap 定义xml文件映射这个字段时的xml字符串 string empty
1.18 key 如果服务器端没有定义id,可以设置字段为行号,只有一个字段可以设置此属性,只认可第1个,其他的将被忽略. boolean false
1.19 name 设置此字段的唯一名称,此属性是必须要设置的, string empty
1.20 label 当colNames为空,则标题显示此设置.如果colNames数组和此设置同时为空,则标题显示name属性. string empty
1.21 resizable 设置此字段是否可编辑 boolean true
1.22 search 该字段是否允许搜索(查询) boolean true
1.23 stype 设置搜索时的数据类型 string text
1.24 searchoptions 配置搜索选项 array empty array
1.24.1 dataUrl 该属性只适用于 stype:’select’ string empty
1.24.2 dataInit 等同于editoptions的dataInit function null
1.24.3 dataEvents 等同于editoptions的dataEvents array empty array
1.24.4 attr 可以设置创建的元素的有效属性 object null
1.24.5 searchhidden 该字段隐藏时,此属性可控制是否可搜索 boolean false
1.24.6 defaultValue 默认值 string empty
1.24.7 sopt 比较运算符,可任意组合('eq','ne','lt','le','gt','ge','bw','bn','in','ni','ew','en','cn','nc')array empty array 
等于 eq = 
不等于 ne <> 
小于 lt < 
小于等于 le <= 
大于 gt > 
大于等于 ge >= 
以*开头 bw like 
不以*开头 bn not like 
在 in in 
不在 ni not in 
以*结尾 ew like 
不以*结尾 en not like 
包含 cn like 
不包含 nc not like 
1.25 sortable 设置该字段是否进行排序 boolean true
1.26 sorttype 排序的数据类型 string text
1.27 width 宽度,不能设置百分比 number 150
     
2.0 navGrid 功能按钮(增删改查,搜,刷新)设置
2.1 top 距离顶端的象素 number(integer) 0
2.2 left 距离左边的象素 number(integer) 0
2.3 width 宽度 number(integer) 300
2.4 height 高度 number(integer) auto
2.5 dataheight 表单内容距离按钮高度 number(integer) auto
2.6 modal 是否模态窗体 boolean false
2.7 drag 是否可拖动 boolean true
2.8 resize 是否可改变大小 boolean true
2.9 url 提交的URL,如果设置则替换editurl string empty
2.10 mtype 请求类型post | get string post
2.11 editData 提交到服务器的数据 array empty array
2.12 recreateForm 每次操作是否创建新的表单 boolean false
2.13 jqModal 设置为true使用存在的jqModal插件的对话框。如果被设置为true和插件不存在jqGrid使用它自己的方式来创造对话框, 比如会影响到日期插件,true和false不同的效果 boolean true
2.14 addedrow %
2.15 topinfo 头部信息 string empty
2.16 bottominfo 底部信息 string empty
2.17 saveicon 保存的图片,第一项启用/禁用的图片, 第二个项目告诉哪里放置图片到文本的左或右. 第三项对应的有效UI图片样式 [true,”left”,”ui-icon-disk”]
2.18 closeicon 取消的图片同上 [true,”left”,”ui-icon-close”]
2.19 savekey 保存的快捷键,默认回车 [false,13]
2.20 navkeys 移动上个,下个的快捷键 ,默认上下箭头 [false,38,40]
2.21 checkOnSubmit 保存时,是否弹出再次确认对话框,仅用在编辑模式 boolean false
2.22 checkOnUpdate 取消时,是否弹出再次确定对话框,仅用在新增和编辑模式 boolean false
2.23 closeAfterAdd 添加模式时,添加记录后是否关闭对话框 boolean false
2.24 clearAfterAdd 添加数据时,是否清空上1次的数据 boolean true
2.25 closeAfterEdit 编辑模式时,编辑完成后是否关闭对话框 boolean false
2.26 reloadAfterSubmit 操作完成后,是否重新加载数据 boolean true
2.27 closeOnEscape 是否关联esc键 boolean false
2.28 ajaxEditOptions % object empty object

官方同步更新!如有疑问,联系邮箱:webmaster@mn886.net。感谢jqGrid团队!
全部实例均可正常运行,浏览器建议火狐,谷歌,IE9.0+
原文地址:https://www.cnblogs.com/leolzi/p/7879295.html