jqGrid专题:参数文档

jqGrid基本参数:

名称

类型

描述

默认值

可修改

url

string

获取数据的地

 

 

datatype

string

从服务器端返回的数据类型,默认xml。可选类型:xmllocaljsonjsonnpscriptxmlstringjsonstringclientside

 

 

mtype

string

ajax提交方式。POST或者GET,默认GET

 

 

colNames

Array

列显示名称,是一个数组对

 

 

colModel

Array

常用到的属性:name 列显示的名称;index 传到服务器端用来排序用的列名称;width 列宽度;align 对齐方式;sortable 是否可以排

 

 

pager

string

定义翻页用的导航栏,必须是有效的html元素。翻页工具栏可以放置在html页面任意位

 

 

rowNum

int

grid上显示记录条数,这个参数是要被传递到后

 

 

rowList

array

一个下拉选择框,用来改变显示记录数,当选择时会覆盖rowNum参数传递到后

 

 

sortname

string

默认的排序列。可以是列名称或者是一个数字,这个参数会被提交到后

 

 

viewrecords

boolean

定义是否要显示总记录

 

 

caption

string

表格名

 

 

ajaxGridOptions[a1] 

object

ajax参数进行全局设置,可以覆盖ajax

null

ajaxSelectOptions[a2] 

object

ajaxselect参数进行全局设

null

altclass

String

用来指定行显示的css,可以编辑自己的css文件,只有当altRows设为 ture时起作

ui-priority-secondary

 

altRows

boolean

设置表格 zebra-striped 

 

 

autoencode

boolean

url进行编

false

autowidth

boolean

如果为ture时,则当表格在首次被创建时会根据父元素比例重新调整表格宽度。如果父元素宽度改变,为了使表格宽度能够自动调整则需要实现函数:setGridWidth

false

cellLayout

integer

定义了单元格padding + border 宽度。通常不必修改此值。初始值

5

cellEdit

boolean

启用或者禁用单元格编辑功

false

cellsubmit

String

定义了单元格内容保存位

‘remote’

cellurl

String

单元格提交的url

空值

datastr

String

xmlstring或者jsonstring

空值

deselectAfterSort

boolean

只有当datatypelocal时起作用。当排序时不选择当前

true

direction

string

表格中文字的显示方向,从左向右(ltr)或者从右向左(rtr

ltr

editurl

string

定义对form编辑时的url

空值

emptyrecords

string

当返回的数据行数为0时显示的信息。只有当属性 viewrecords 设置为ture时起作

 

ExpandColClick

boolean

当为true时,点击展开行的文本时,treeGrid就能展开或者收缩,不仅仅是点击图

true

ExpandColumn

string

指定那列来展开tree grid,默认为第一列,只有在treeGridtrue时起作

空值

footerrow[a3] 

boolean

当为true时,会在翻页栏之上增加一

false

forceFit

boolean

当为ture时,调整列宽度不会改变表格的宽度。当shrinkToFit false时,此属性会被忽

false

gridstate

string

定义当前表格的状态:'visible' or 'hidden'

visible

gridview

boolean

构造一行数据后添加到grid中,如果设为true则是将整个表格的数据都构造完成后再添加到grid中,但treeGrid, subGrid, or afterInsertRow 不能

false

height

mixed

表格高度,可以是数字,像素值或者百分

150

hiddengrid

boolean

当为ture时,表格不会被显示,只显示表格的标题只有当点击显示表格的那个按钮时才会去初始化表格数据

false

hidegrid

boolean

启用或者禁用控制表格显示、隐藏的按钮,只有当caption 属性不为空时起

true

hoverrows

boolean

当为falsemouse hovering会被禁

false

jsonReader

array

描述json 数据格式的数

 

lastpage

integer

只读属性,定义了总页

0

lastsort

integer

只读属性,定义了最后排序列的索引,从0

0

loadonce

boolean

如果为ture则数据只从服务器端抓取一次,之后所有操作都是在客户端执行,翻页功能会被禁

false

loadtext

string

当请求或者排序时所显示的文字内

Loading....

loadui

string

当执行ajax请求时要干什么。disable禁用ajax执行提示;enable默认,当执行ajax请求时的提示; block启用Loading提示,但是阻止其他操

enable

multikey

string

只有在multiselect设置为ture时起作用,定义使用那个key来做多选。shiftKeyaltKeyctrlKey

空值

multiboxonly

boolean

只有当multiselect = true.起作用,当multiboxonly ture时只有选择checkbox才会起作

false

multiselect

boolean

定义是否可以多

false

multiselectWidth

integer

multiselecttrue时设置multiselect列宽

20

page

integer

设置初始的页

1

pagerpos

string

指定分页栏的位

center

pgbuttons

boolean

是否显示翻页按

true

pginput

boolean

是否显示跳转页面的输入

true

pgtext

string

当前页信

 

prmNames

array

Default valuesprmNames: {page:“page”,rows:“rows”, sort: “sidx”,order: “sord”, search:“_search”, nd:“nd”, npage:null} 当参数为null时不会被发到服务器

none

postData

array

此数组内容直接赋值到url上,参数类型:{name1:value1…}

空array

reccount

integer

只读属性,定义了grid中确切的行数。通常情况下与records属性相同,但有一种情况例外,假如rowNum=15,但是从服务器端返回的记录数是20,那么records值是20,但reccount值仍然为15,而且表格中也只显示15条记录

0

recordpos

string

定义了记录信息的位置: left, center, right

right

records

integer

只读属性,定义了返回的记录

none

recordtext

string

显示记录数信息。{0} 为记录数开始,{1}为记录数结束。viewrecordsture时才能起效,且总记录数大于0时才会显示此信

 

 

resizeclass

string

定义一个class到一个列上用来显示列宽度调整时的效

空值

rowList

array

一个数组用来调整表格显示的记录数,此参数值会替代rowNum参数值传给服务器端

[]

rownumbers

boolean

如果为ture则会在表格左边新增一列,显示行顺序号,从1开始递增。此列名为'rn'.

false

rownumWidth

integer

如果rownumberstrue,则可以设置column的宽

25

savedRow

array

只读属性,只用在编辑模式下保存数

空值

scroll

boolean

创建一个动态滚动的表格,当为true时,翻页栏被禁用,使用垂直滚动条加载数据,且在首次访问服务器端时将加载所有数据到客户端。当此参数为数字时,表格只控制可见的几行,所有数据都在这几行中加

false

scrollOffset

integer

设置垂直滚动条宽

18

scrollrows

boolean

当为true时让所选择的行可

false

selarrrow

array

只读属性,用来存放当前选择的

array

selrow

string

只读属性,最后选择行的id

null

shrinkToFit

boolean

此属性用来说明当初始化列宽度时候的计算类型,如果为ture,则按比例初始化列宽度。如果为false,则列宽度使用colModel指定的宽

true

sortable

boolean

是否可排

false

sortname

string

排序列的名称,此参数会被传到后

空字符串

sortorder

string

排序顺序,升序或者降序(asc or desc

asc

subGrid

boolean

是否使用suggrid

false

subGridModel

array

subgrid

array

subGridType

mixed

如果为空则使用表格的dataType

null

subGridUrl

string

加载subgrid数据的urljqGrid会把每行的id值加到url

空值

subGridWidth

integer

subgrid列的宽

20

toolbar

array

表格的工具栏。数组中有两个值,第一个为是否启用,第二个指定工具栏位置(相对于body layer),如:[true,”both”] 。工具栏位置可选值:“top”,”bottom”, “both”. 如果工具栏在上面,则工具栏id“t_”+表格id;如果在下面则为 “tb_”+表格id;如果只有一个工具栏则为 “t_”+表格id

[false,'']

totaltime

integer

只读属性,计算加载数据的时间。目前支持xmljson

0

treedatatype

mixed

数据类型,通常情况下与datatype相同,不会

null

treeGrid

boolean

启用或者禁用treegrid

false

treeGridModel

string

treeGrid所使用的方

Nested

treeIcons

array

树的图标,默认值:{plus:'ui-icon-triangle-1-e',minus:'ui-icon-triangle-1-s',leaf:'ui-icon-radio-off'}

 

treeReader

array

扩展表格的colModel且加在colModel定义的后

 

tree_root_level

numeric

r oot元素的级别

0

userData

array

request中取得的一些用户信

array

userDataOnFooter

boolean

当为true时把userData放到底部,用法:如果userData的值与colModel的值相同,那么此列就显示正确的值,如果不等那么此列就为

false

viewrecords

boolean

是否要显示总记录

false

viewsortcols

array

定义排序列的外观跟行为。数据格式:[false,'vertical',true].第一个参数是说,是否都要显示排序列的图标,false就是只显示 当前排序列的图标;第二个参数是指图标如何显示,vertical:排序图标垂直放置,horizontal:排序图标水平放置;第三个参数指单击功 能,true:单击列可排序,false:单击图标排序。说明:如果第三个参数为false则第一个参数必须为ture否则不能排

 

width

number

如果设置则按此设置为主,如果没有设置则按colModel中定义的宽度计

none

xmlReader

array

xml数据结构的描

其中ColModel 属性参数文档,设置表格列的属性:

属性

数据类型

备注

默认值

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:”${ctx}/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=’${ctx}/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

用在当datatypelocal时,定义搜索列的类型,可选值: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

 

幸福是奋斗出来的
原文地址:https://www.cnblogs.com/ydchw/p/3022339.html