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 ...
随机推荐
- MySQL基础SQL命令---增删改查
1.表操作: create table tableName (id int(6) not null primary key auto_increatment,name varchar(10) not ...
- Redis的两种数据持久化方式比较
RDB(Redis Database) 本质:基于时间点的快照 优点: 1.RDB格式文件体积小. 2.可以通过脚本执行bgsave(非阻塞)或者save(阻塞)命令自定义时间点进行备份. 3.可以保 ...
- linux系统启动报错:[contains a file system with errors, check forced]的解决方法参考
1.解决参考一Press enter for maintenance(or type Control-D to continue):/dev/sda3 contains a file system w ...
- JS三座大山再学习 ---- 原型和原型链
本文已发布在西瓜君的个人博客,原文传送门 ## 前言 西瓜君之前学习了JS的基础知识与三座大山,但之后工作中没怎么用,印象不太深刻,这次打算再重学一下,打牢基础.冲鸭~~ 原型模式 JS实现继承的方式 ...
- python中列表(list)函数及使用
序列是Python中最基本的数据结构.序列中的每个元素都分配一个数字 - 它的位置,或索引,第一个索引是0,第二个索引是1,依此类推. Python有6个序列的内置类型,但最常见的是列表和元组. 序列 ...
- Spring Cloud Turbine 知识点
Turbine 默认使用 Eureka 作为注册中心:如果使用 Consul 作为注册中心,需要排除掉 Eureka:pom.xml 如下: <dependency> <groupI ...
- JMeter基础【第三篇】JMeter5.1元件作用域及执行顺序
执行顺序,大家可以实践验证,加深印象. 最后,给大家说一个万能且保险的方法:放到对应的取样器下面即可.
- opencart忘记登录密码怎么办
今天一位客户问opencart忘记登录密码怎么办,他们公司内部有几位员工同时在管理,可能是哪位同事把密码给改了没有跟大家说,现在都登录不了.这个只能数据库修改了.进入opencart的数据库,找到oc ...
- Python学习笔记7 头文件的添加规则(转载)
转载自:https://www.cnblogs.com/taurusfy/p/7605787.html ************************************************ ...
- py 包和模块,软件开发目录规范
目录 py 包和模块,软件开发目录规范 什么是包? 什么是模块? 软件开发目录规范 py 包和模块,软件开发目录规范 什么是包? 包指的是内部包__init__.py的文件夹 包的作用: 存放模块,包 ...