<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\" />&nbsp;&nbsp;"; if (rowObject[46] == "True" || rowObject[46] == "true")
{
imgStr = imgStr + "<img src=\"../Content/images/reinspection.png\" title=\"Re-Inspection\" />&nbsp;&nbsp;";
} 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参考实例的更多相关文章

  1. jQuery jqgrid 应用实例

    1.html <div class="ibox-content"> <div class=\"jqGrid_wrapper\"> < ...

  2. HashTable的典型用法以及参考实例

    Get-ADComputer -Identity "cnhzpd-f7sc83x" | select -property @{name="computername&quo ...

  3. 编译安装nginx并修改版本头信息—参考实例

    今天做实验的时候,想起我那台yum安装的nginx+php-fpm+mysql服务器上的nginx版本有点低了,并且还要加两个第3方模块,就去nginx官网下载了最新稳定版nginx-1.0.6,好了 ...

  4. oracle 存储过程、游标参考实例

    create or replace procedure INIT_DICT_QUEUECODE(p_queueId int,p_paramType in varchar2,p_queenName in ...

  5. PHP实现微信扫码自动登陆与注册,参考实例

    微信开发已经是现在phper必须要掌握的一项基本的技术了,其实做过微信开发的都知道微信接口非常的强大做起来也非常的简单,这里我们一起来看一个微信自动登陆注册的例子. php 微信扫码 pc端自动登陆注 ...

  6. flex简单参考实例

    <!DOCTYPE html> <html> <head> <title></title> <style type="tex ...

  7. jqGrid资源

    在比较多个Grid后决定以后还是用jqGrid,并且是free-jqgrid分支版,  jqgrid优点很多: 加载大量数据时效率很好, 支持排序, 支持过滤, 支持resize, 支持分页, 支持e ...

  8. sip常用消息实体参考(系网上摘抄,感谢分享)

    1.MESSAGE消息       1)头字段填写说明       Call-id:                 必选       CSeq:                   必选       ...

  9. RequireJS实例分析【转】

    转自http://www.cnblogs.com/xing901022/p/4658548.html 随着JS越来越庞大,已经不仅仅是以前复制粘贴做特效的时代了,JS越来越偏向于业务逻辑与应用.恰逢N ...

随机推荐

  1. redis常用操作(测试必备)

    连接redis redis的安装及基础配置,参考:https://www.cnblogs.com/UncleYong/p/9882843.html redis中,数据是key-value方式存储,ke ...

  2. 线程全局修改、死锁、递归锁、信号量、GIL以及多进程和多线程的比较

    线程全局修改 x = 100 def func1(): global x print(x) changex() print(x) def changex(): global x x = 50 func ...

  3. Shell里的特殊符号

    Shell里的特殊符号: (1)单引号: 由单引号括起来的符号都作为普通字符处理,他们都失去了特殊意义. (2)双引号: 除美元符号($).倒引号.反斜线(\)仍保留特殊含义外,其余符号都作为普通字符 ...

  4. PATA1012The Best Rank(25分)

    To evaluate the performance of our first year CS majored students, we consider their grades of three ...

  5. ZROI 暑期高端峰会 A班 Day4 树上数据结构

    FBI Warning:本文含有大量人类的本质之一. 你经历过绝望吗? [ZJOI2007]捉迷藏 询问树上最远黑点对. 动态边分治可以比点分治少一个 \(\log\). bzoj3730 咕了. [ ...

  6. C/C++ 交换两个数,不使用第三个变量, 函数模板来实现

    #include <iostream> template<typename T> void exchangeTwoNumber(T &t1, T &t2): v ...

  7. Android Studio 之 AndroidViewModel

    AndroidViewModel是ViewModel的一个子类,可以直接调用getApplication(),由此可以访问应用的全局资源. 在 MyViewModel 这个类中,此类直接继承自 And ...

  8. django:CBV模式,源码解析

    非常好 DRF执行流程源码解析 https://www.cnblogs.com/suguangti/p/11120793.html https://www.cnblogs.com/haitaoli/p ...

  9. 【视频开发】【计算机视觉】相机标定(Camera calibration)《二》

    简介 摄像机标定(Camera calibration)简单来说是从世界坐标系换到图像坐标系的过程,也就是求最终的投影矩阵 P 的过程,下面相关的部分主要参考UIUC的计算机视觉的课件(网址Sprin ...

  10. nginx开启gzip的方法

    nginx开启gzip的方法 1.vi打开Nginx配置文件 <pre>vi /usr/local/nginx/conf/nginx.conf</pre> 2.找到如下一段,进 ...