jqGrid 各种参数 详解

2023-11-13

JQGrid是一个在jquery基础上做的一个表格控件,以ajax的方式和服务器端通信。
JQGrid Demo 是一个在线的演示项目。在这里,可以知道jqgrid可以做什么事情。

下面是转自其他人blog的一个学习资料,与其说是学习资料,说成查询帮助文档更加合适。

jqGrid学习之 ------------- 安装

jqGrid安装很简单,只需把相应的css、js文件加入到页面中即可。
按照官网文档:

/myproject/css/
            ui.jqgrid.css
            /ui-lightness/
                  /images/
                  jquery-ui-1.7.2.custom.css

 /myproject/js/
            /i18n/
                  grid.locale-bg.js
                  list of all language files
                  ….
            Changes.txt
            jquery-1.3.2.min.js
            jquery.jqGrid.min.js

 

在页面中写法:

Java代码 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">  

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">  

<head>  

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  

<title>My First Grid</title>  

   

<link rel="stylesheet" type="text/css" media="screen" href="css/ui-lightness/jquery-ui-1.7.1.custom.css" />  

<link rel="stylesheet" type="text/css" media="screen" href="js/src/css/ui.jqgrid.css" />  

<link rel="stylesheet" type="text/css" media="screen" href="js/src/css/jquery.searchFilter.css" />  

<style>  

html, body {  

   margin: 0;  

    padding: 0;  

    font-size: 75%;  

}  

</style>  

   

<script src="js/jquery-1.3.2.min.js" type="text/javascript"></script>  

<script src="js/src/grid.loader.js" type="text/javascript"></script>  

   

</head>  

<body>  

...  

</body>  

</html>  

需要说明的是,jquery-ui的字体大小与jqgrid字体大小不一致,故需要在页面上在加上一段
style来指定页面上文字大小。


 

jqGrid皮肤

从3.5版本开始,jqGrid完全支持jquery UI的theme。我们可以从http://jqueryui.com/themeroller/下载我们所需要的theme。当然,你也可以编辑自己的theme。jqGrid
也并不需要把所有的css文件都引入进来,只需导入核心css文件“ui.theme.css ” 以及“ui.core.css”即可,文件位于目录development-bundle/themes下。

jqGrid原理

jqGrid是典型的B/S架构,服务器端只是提供数据管理,客户端只提供数据显示。换句话说,jqGrid可以以一种更加简单的方式来展现你数据库的信息,而且也可以把客户端数据传回给服务器端。
对于jqGrid我们所关心的就是:必须有一段代码把一些页面信息保存到数据库中,而且也能够把响应信息返回给客户端。jqGrid是用ajax来实现对请求与响应的处理。

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时才会显示此信

 

 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

jqGrid 各种参数 详解 的相关文章

随机推荐