jqGrid的用法

jqGrid是一种用来显示网格数据的jQuery插件,通过使用jqGrid可以轻松实现前端页面与后台数据的ajax异步通信。文档比较全面,其官方网址为:http://www.trirand.com。效果如下图所示:


js代码如下:

function initData(p) {
    $("#customerMainList").jqGrid({
        url: "",
        datatype: "local",
        colNames: ['编号', '客户姓名(跟进)', '类型', '添加人', '分配给', '期望区域', '期望小区', '期望面积', '户型', '期望装修', '期望楼层', '期望总价', '状态', '添加时间', '操作'],
        colModel: [
   		{ name: 'Id', index: 'Id', formatter: tranCustId, width: 70, align: "center" },
   		{ name: 'CustName', index: 'CustName', formatter: transName, width: 98, align: "center" },
   		{ name: 'BusinessType', index: 'BusinessType', width: 60, align: "center" },
   		{ name: 'CreateUserName', index: 'CreateUserName', width: 55, align: "center" },
   		{ name: 'ExeUserName', index: 'ExeUserName', width: 65, align: "center" },
   		{ name: 'ExpArea', index: 'ExpArea', width: 70, align: "center" },
   		{ name: 'ExpSeqv', index: 'ExpSeqv', width: 77, align: "center" },
   		{ name: 'ExpAcre', index: 'ExpAcre', width: 70, align: "center" },
   		{ name: 'ExpShi', index: 'ExpShi', formatter: transHuX, width: 67, align: "center" },
   		{ name: 'ExpZhuangX', index: 'ExpZhuangX', width: 60, align: "center" },
   		{ name: 'ExpFloor', index: 'ExpFloor', width: 59, align: "center" },
   		{ name: 'ExpPriceT', index: 'ExpPriceT', formatter: transExpPrice, width: 59, align: "center" },
        { name: 'S2', index: 'S2', formatter: custStates, width: 53, align: "center" },
   		{ name: 'CreateDate', index: 'CreateDate', formatter: transDate, width: 65, align: "center" },
   		{ name: 'id', index: 'id', formatter: transOp, width: 74, align: "center" }

   	],
        rowNum: 20,
        hoverrows: true,
        rowList: [15, 20, 25, 30, 35, 40, 45, 50],
        pager: '#pager2',
        sortname: 'Id',
        viewrecords: true,
        sortorder: "desc",
        height: "100%", emptyrecords: "没有记录", forceFit: true, gridview: true, pginput: true,
        prmNames: { page: "page", rows: "rows", sort: "sidx", order: "sord", search: "_search", nd: "nd", npage: null },
        viewsortcols: [false, 'vertical', true],
        onSelectRow: function (rowid, status) {
            ShowCustomerDetail(rowid, true);
        }
    });
    $("#customerMainList").jqGrid('navGrid', '#pager2', { edit: false, add: false, del: false, refresh: false, search: false });
    refreshData(p);
}
设置jqGrid显示的列,分页等基本信息,需要注意的是colNames和colModel对应的字段信息要一致,onSelectRow事件表示的是行选中事件,在这里可以在选中行的同时弹出该记录的详情页面。
function refreshData(p) {
    cust_p = p;
    $("input[type='button']").attr("disabled", true);
    var where = calcWhere();
    $("#customerMainList").jqGrid("setGridParam", {
        url: "xxxx.aspx" + where,    //设置表格的url
        datatype: "json", page: p
    }).trigger("reloadGrid");
    $("input[type='button']").attr("disabled", false);
    $(".ui-jqgrid-bdiv div").css("position", "");
}
设置jqGrid请求的url,参数等信息,返回的是json格式。

.net论坛:http://bbs.netluntan.com,群:121058751

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值