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 ...
随机推荐
- 服务器学习--Linux基本操作指令
小编后续会持续更新 1.修改服务器的hostname [root@mexihq ~]# hostname [root@mexihq ~]# hostnamectl set-hostname xxx P ...
- STM32系列芯片命名规范
1.STM32的基础知识 STM32是意法半导体公司,基于ARM Cortex®-M0,M0+,M3, M4和M7内核生产的系列通用MCU.截止当前时间为止(20190515),STM32有STM32 ...
- dapi 基于Django的轻量级测试平台七 怎样部署到生产环境
QQ群: GitHub:https://github.com/yjlch1016/dapi Nginx+uWSGI 前置条件:以下所有操作均在root账号下面进行如果不是root用户请注意权限问题因为 ...
- 让istio中的jaeger跑起来
现在的水平,仅止于让它跑起来.:) 同样的环境,microk8s+istio. 步骤如下: 一,使用kubectl get pod -n istio-system查看所有istio的POD运行正常. ...
- 洛谷P2680 运输计划(倍增LCA + 树上差分 + 二分答案)
[题目链接] [思路]: 根据题意可以明显看出,当所有任务都完成时的时间是最终的结果,也就是说本题要求,求出最小的最大值. 那这样的话就暗示了将答案二分,进行check. [check方法]: 如果说 ...
- wpf学习资料链接(做记录)
1.wpf快速入门系列:https://www.cnblogs.com/zhili/tag/WPF/
- Alibaba Cloud SDK for Java,知识点
资料 网址 Alibaba Cloud SDK for Java https://help.aliyun.com/document_detail/52740.html?spm=a2c4g.111742 ...
- MySQL 官方测试库
MySQL 官方测试库 github 地址 https://github.com/datacharmer/test_db MySQL 文档地址 https://dev.mysql.com/doc/em ...
- arduino驱动步进电机
https://learn.adafruit.com/adafruit-motor-shield-v2-for-arduino/install-software 1安装库 Adafruit_Motor ...
- JavaScript遍历