JqGrid参考实例
<div class="gridtable mt5">
<table id="tbList"></table>
<div id="tbListPager">
</div>
</div> jQuery("#tbList").jqGrid({
url: urlPath,//URL地址
datatype: "json",
mtype: "POST",
postData:{ID:123},
colModel: [
{ label: "ID", name: "ID", index: "ID", hidden: true, excluded: true },
{ label: "ServiceTypeID", name: "ServiceTypeID", index: "ServiceTypeID", hidden: true, excluded: true },
{
label: "Booking No.", bound: true, name: "BookingNumber", index: "BookingNumber", width: 210, align: "center", resizable: false, formatter: showBookingLink, unformat: function (cellvalue, options, cell) {
return $("a", cell).text();
}, hidden: convertToBoolean("@(helper.IsColumnHidden("BookingNumber"))")
},
{ label: "Inspection Leader", name: "InspectionLeader", index: "InspectionLeader", width: 120, align: "center", sortable: false, resizable: false, formatter: InspectionLeaderFormatter, hidden: convertToBoolean("@(helper.IsColumnHidden("InspectionLeader"))") },//formatter格式化单元格内容.
{label: "Role in Job", name: "InspectorRole", index: "InspectorRole", align: "center", formatter: function (cellvalue, options, rowObject) {
var options = "";
if (cellvalue == 1) {
options += "<option value=\"\"></option><option value=\"1\" selected>Leader</option><option value=\"2\">Member</option>";
} else if (cellvalue == 2) {
options += "<option value=\"\"></option><option value=\"1\">Leader</option><option value=\"2\" selected>Member</option>";
}
else {
options += "<option value=\"\" selected></option><option value=\"1\">Leader</option><option value=\"2\">Member</option>";
} if ('@isEditable' == "True" && (inspectionDataInput != "" || action == "")) {
return "<select style=\"width:80px;\" onchange=\"changeInspectorRole('" + rowObject[5] + "','" + rowObject[6] + "','" + rowObject[7] + "', this)\">" + options + "</select>";
} return "<select style=\"width:80px;\" disabled onchange=\"changeInspectorRole('" + rowObject[5] + "','" + rowObject[6] + "','" + rowObject[7] + "', this)\">" + options + "</select>";
}
}
],
pager: jQuery("#tbListPager"), //分页控件的id
gridViewID: '@gridViewID',
autowidth: true,//自动调整列宽
hidegrid: false, //是否隐藏grid控件
rownumbers: false, //在最左边是否显示序列号,自增长的
rowNum: GRID_ROWNUM, //每页显示的数据量
rowList: GRID_ROWLIST, //可以改变每页的显示数量,以dropdown列出。
sortname: "SubmittedDate", //默认的排序字段
sortorder: "DESC", //默认的排序方式
viewrecords: true, //是否显示总记录数。
height: "100%", //高度.
sortable: true,
loadError: function (xhr, status, error) { alert(GRID_ERRORMESSAGE); },
width: "3900", //宽度
imgpath: "/Content/themes/base/images", //CSS中用到的图片地址
caption: "Previous Report Reference", //显示在Grid左上角的名称。
alterColor: true,
multiselect: false, //是否允许选择多行带第一列带checkbox
shrinkToFit: true,
showSelectBox: false,
exportName: "SchedulingBookingList",
loadComplete: function () {
rowEventHandle();
},//JqGrid加载完成后执行
onSelectRow: function (id) {
if (parseFloat(chooseLevel) > 1) { //可选择地址
$("#divAddress").show();
$("#divContact").hide();
var result = $("#tbCustomerList").jqGrid("getRowData", id);
loadCustomerAddress(result.CustomerID);
}
} }); function rowEventHandle(){}
function changeInspectorRole(){} //格式化JqGrid单元格内容(显示成带图片的超链接)
function showBookingLink(cellvalue, options, rowObject) {
var imgStr = "";
if (rowObject[7] == "True" || rowObject[7] == "true")
imgStr = imgStr + "<img src=\"../Content/images/firstinspection.png\" title=\"First Inspection\" data-name=\"firstinspection\" /> "; if (rowObject[46] == "True" || rowObject[46] == "true")
{
imgStr = imgStr + "<img src=\"../Content/images/reinspection.png\" title=\"Re-Inspection\" /> ";
} return imgStr + "<a href=\"javascript:void(0)\" onclick=\"showSubMenu(11100, viewBookingDetail,'" + rowObject[0] + "')\">" + cellvalue + "</a>";
} function InspectionLeaderFormatter(cellvalue, options, rowObject) {
if (String(rowObject[8]).toLowerCase() == "true" || $("span[functionidattribute=100201]").is(":hidden")) {
return "<input type=\"text\" name=\"InspectionLeader\" style=\"width:100%\" title=\"" + cellvalue + "\" value=\"" + cellvalue + "\" class=\"readonly-bgcolor\" readonly />";
} var searchInspectorStr = getSearchInspectorHTML(rowObject, "0");
var countryCode = rowObject[1]; var cellValueFormatStr = "<input type=\"text\" name=\"InspectionLeader\" maxlength=\"50\" style=\"width:85%\" title=\"" + cellvalue + "\" onchange=\"CheckInspectorValid(this, this.value, '" + countryCode + "')\" value=\"" + cellvalue + "\" />";
return cellValueFormatStr + searchInspectorStr;
} //加载/刷新JqGrid
function QueryList() {
jQuery("#tbList").jqGrid("setGridParam", { postData: {ID:123,name:"张三"}, page: 1 }).trigger("reloadGrid");
} //编辑JqGrid选中行数据
function EditCheckingItem() {
var SelectRow= $("#tbList").jqGrid("getGridParam", "selrow");//获取选中行对象(单选)
if (SelectRow) {
var RowObj = $("#tbList").jqGrid("getRowData", SelectRow);//获取选中行的数据对象
var id = RowObj.ID;
}
else {
alert("Please select a record!");
}
} //编辑JqGrid选中行数据
function EditCheckingItem() {
var SelectRows = $("#tbList").jqGrid("getGridParam", "selarrrow");//获取选中行对象(多选)
if (SelectRows && SelectRows.length > 0) { for (var i = 0; i < SelectRows.length; i++) {
var RowObj = $("#tbList").getRowData(SelectRows[i]);
var id=RowObj.ID;
} }
else {
alert("Please select a record!");
}
}
JqGrid参考实例的更多相关文章
- jQuery jqgrid 应用实例
1.html <div class="ibox-content"> <div class=\"jqGrid_wrapper\"> < ...
- HashTable的典型用法以及参考实例
Get-ADComputer -Identity "cnhzpd-f7sc83x" | select -property @{name="computername&quo ...
- 编译安装nginx并修改版本头信息—参考实例
今天做实验的时候,想起我那台yum安装的nginx+php-fpm+mysql服务器上的nginx版本有点低了,并且还要加两个第3方模块,就去nginx官网下载了最新稳定版nginx-1.0.6,好了 ...
- oracle 存储过程、游标参考实例
create or replace procedure INIT_DICT_QUEUECODE(p_queueId int,p_paramType in varchar2,p_queenName in ...
- PHP实现微信扫码自动登陆与注册,参考实例
微信开发已经是现在phper必须要掌握的一项基本的技术了,其实做过微信开发的都知道微信接口非常的强大做起来也非常的简单,这里我们一起来看一个微信自动登陆注册的例子. php 微信扫码 pc端自动登陆注 ...
- flex简单参考实例
<!DOCTYPE html> <html> <head> <title></title> <style type="tex ...
- jqGrid资源
在比较多个Grid后决定以后还是用jqGrid,并且是free-jqgrid分支版, jqgrid优点很多: 加载大量数据时效率很好, 支持排序, 支持过滤, 支持resize, 支持分页, 支持e ...
- sip常用消息实体参考(系网上摘抄,感谢分享)
1.MESSAGE消息 1)头字段填写说明 Call-id: 必选 CSeq: 必选 ...
- RequireJS实例分析【转】
转自http://www.cnblogs.com/xing901022/p/4658548.html 随着JS越来越庞大,已经不仅仅是以前复制粘贴做特效的时代了,JS越来越偏向于业务逻辑与应用.恰逢N ...
随机推荐
- CentOS设置静态IP及Samba等基础设置
1. CentOS7设置静态IP CentOS的网卡IP配置文件/etc/sysconfig/network-scripts/ifcfg-网卡名字. 配置参数解析: BOOTPROTO="s ...
- Android Studio总结
课程背景 相信大家对Android Studio已经不陌生了,Android Studio是Google于2013 I/O大会针对Android开发推出的新的开发工具,目前很多开源项目都已经在采用,G ...
- 洛谷P4549 裴蜀定理 / Min
原题链接 题目描述 给出n个数(A1...An)现求一组整数序列(X1...Xn)使得S=A1X1+...AnXn>0,且S的值最小 输入输出格式 输入格式: 第一行给出数字N,代表有N个数 下 ...
- Linux 换 jdk 版本 环境没有生效
Linux 换 jdk 版本 环境没有生效 把 jdk 1.7 换成 1.8, 路径设置好了后 用了下面两个都没有生效 . /etc/profile source ~/.bashrc 还是 jdk 1 ...
- 简述 gevent模块的作用和应用场景。
当一个greenlet遇到IO操作时,比如访问网络,就自动切换到其他的greenlet,等到IO操作完成, 再在适当的时候切换回来继续执行.由于IO操作非常耗时,经常使程序处于等待状态, 有了geve ...
- LRU Algorithm Gym - 102394L (HASH)
LRU Algorithm \[ Time Limit: 1000 ms\quad Memory Limit: 524288 kB \] 题意 给出 \(n\) 个数字和 \(m\) 次查询. 每次询 ...
- ajax和json的优缺点
ajax:AJAX全称是"Asynchronous JavaScript and XML"(异步Javascript和XML),是一种创建交互式网页应用的网页开发技术. 优点: 1 ...
- FFT学习
看了一天的多项式的内容,看博客的时候好像还是那么回事,一看题,哇塞,发现我其实连卷积是啥都没看懂. qtdydb,背板子. 不知道卷积是啥就很伤了. P3803 [模板]多项式乘法(FFT) #inc ...
- Ubuntu 修改apt-get源为阿里源
原文件重命名备份 sudo mv /etc/apt/sources.list /etc/apt/source.list.bak 编辑源列表文件 sudo vim /etc/apt/sources.li ...
- pyhon项目之后pexpect使用
pyhon项目之后pexpect使用1.安装pip3.6 install pexpect 实例1 ssh 登陆linux 服务器,并且执行命令 #!/usr/bin/env python3.6# -* ...