JqGrid网页电子表格的关键-jqGrid({参数})

1、jqGrid的固定写法:

<script type="text/javascript">
$(function(){
$("#list").jqGrid({参数类表})
});
</script>

2.其中参数类表是个很关键的参数,下面做一个详细的介绍

Property Description
url Tells us where to get the data. Typically this is a server-side function with a connection to a database which returns the appropriate information to be filled into the Body layer in the grid 从后台获取要显示数据的地址
datatype This tells jqGrid the type of information being returned so it can construct the grid. In this case, we tell the grid that we expect xml data to be returned from the server, but other formats are possible. For a list of all available datatypes refer to API Methods告诉我们数据的类型json、xml等格式还可以本地
mtype Tells us how to make the ajax call: either 'GET' or 'POST'. In this case, we will use the GET method to retrieve data from the server获取数据的方法
colNames An array in which we place the names of the columns. This is the text that appears in the head of the grid (Header layer). The names are separated with commas为一个数组,用来显示的头部标题
colModel

An array that describes the model of the columns. This is the most important part of the grid. Here I explain only the options used above. an array that describes the model of the columns. This is the most important part of the grid. Here I explain only the options used above. For the complete list of options see colModel API
name the name of the column. This name does not have to be the name from database table, but later we will see how we can use this when we have different data formats列的名字
index the name passed to the server on which to sort the data (note that we could pass column numbers instead). Typically this is the name (or names) from database – this is server-side sorting, so what you pass depends on what your server expects to receive索引也就是你的这一列的排列顺序
width the width of the column, in pixels行的宽度(默认)
align the alignment of the column排列的方式居中还是靠左
sortable Specifies if the data in the grid can be sorted on this column; if false, clicking on the header has no effect(是否可以排续)

pager Defines that we want to use a pager bar to navigate through the records. This must be a valid html element; in our example we gave the div the id of “pager”, but any name is acceptable. Note that the Navigation layer (the “pager” div) can be positioned anywhere you want, determined by your html; in our example we specified that the pager will appear after the Body layer.显示页数
rowNum Sets how many records we want to view in the grid. This parameter is passed to the url for use by the server routine retrieving the data
rowList

An array to construct a select box element in the pager in which we can change the number of the visible rows. When changed during the execution, this parameter replaces the rowNum parameter that is passed to the url

sortname Sets the initial sorting column. Can be a name or number. This parameter is added to the url for use by the server routine
viewrecords Defines whether we want to display the number of total records from the query in the pager bar
caption Sets the caption for the grid. If this parameter is not set the Caption layer will be not visible

连接地址:http://www.trirand.com/jqgridwiki/doku.php?id=wiki:first_grid#behind_the_scenesgrid_data

你可能感兴趣的:(jqGrid)