代码人生的小狗窝

一行行枯燥的代码,却描绘出人生的点点滴滴

您现在的位置是:首页>_Web开发

关于jqrid传递参数解决办法

发布时间:2018-10-16浏览(1468)

    关于jqrid传递参数


    页面代码:
    $(function ($)
        {
            var grid_selector = "#grid-table";
            var pager_selector = "#grid-pager";
            $(grid_selector).jqGrid({
                datatype: "json",
                url: '/Loan/Index',
                mtype: 'POST',
                height: 400,
                colNames: [' ', '运单号', '贷款日', '交易状态', '本金', '总金额',''],
                colModel: [
                    {
                        name: 'FactoringId', index: 'FactoringId', width: 80, fixed: true, sortable: false, resize: false,
                        formatter: 'actions',
                        formatoptions: {
                            keys: true,
                            delOptions: { recreateForm: true, beforeShowForm: beforeDeleteCallback },
                        }
                    },
                        { name: 'OrderNo', index: 'OrderNo', width: 120, unformat: aceSwitch },
                        { name: 'CreateTime', index: 'CreateTime', width: 120, sorttype: "date", formatter: 'date', formatoptions: { srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d H:i:s' } },
                        { name: 'RepaymentStatus', index: 'RepaymentStatus', width: 90, sortable: false, edittype: "select", formatter: statusSwitch },
                        { name: 'LoanAmount', index: 'LoanAmount', width: 80 },

                        {
                            name: 'TotalAmount', index: 'TotalAmount', width: 80, formatter: function (cellvalue, options, cell)
                            {
                                return cellvalue + '元';
                            }
                        },
                        { name: 'Details', index: 'Details', width: 60 }

                ],
                //定义是否要显示总记录数
                viewrecords: true,
                //在grid上显示记录条数,这个参数是要被传递到后台
                rowNum: 10,
                //一个下拉选择框,用来改变显示记录数,当选择时会覆盖rowNum参数传递到后台
                rowList: [10, 20, 30],
                //定义翻页用的导航栏
                pager: pager_selector,

                //列表页脚的显示修改
                pgtext: "第 {0} 共 {1}",
                recordtext: "显示条目 {0} - {1} 共 {2}",

                //设置表格 zebra-striped 值
                altRows: true,
                //toppager: true,
                //定义是否可以多选
                multiselect: true,
                //只有当multiselect = true.起作用,当multiboxonly 为ture时只有选择checkbox才会起作用,
                multiboxonly: true,

                //当从服务器返回响应时执行,xhr:XMLHttpRequest 对象
                loadComplete: function ()
                {
                    var table = this;
                    setTimeout(function ()
                    {
                        styleCheckbox(table);
                        updateActionIcons(table);
                        updatePagerIcons(table);
                        enableTooltips(table);
                    }, 0);
                },

                //定义对form编辑时的url
                // editurl: "/Refuel/Edit",//nothing is saved
                // editurl: "/Refuel/Edit",//nothing is saved
                //表头
                caption: "<span style='color:#FFAF60'>贷款管理</span>" + "<a href='/Loan/RepayList' style='color:#fff;padding-left:40px;'>还款记录</a>" + "<a href='/Loan/RepayOverList' style='color:#fff;padding-left:40px;'>逾期记录</a>",
                
                //如果为ture时,则当表格在首次被创建时会根据父元素比例重新调整表格宽度
                autowidth: true,



                gridComplete: function ()
                {
                    var ids = jQuery("#grid-table").jqGrid('getDataIDs');
                    for (var i = 0; i < ids.length; i++)
                    {
                        var id = ids[i];
                        var DetailsBtn = "<button class='btn-info' id='bootbox-confirm' onclick='Details()'>详情</button>";
                        jQuery("#grid-table").jqGrid('setRowData', ids[i], { Details: DetailsBtn });
                    }
                }
            });

    后台:
     public ActionResult Index(string orderNo) {
                orderNo = "1411091251120367";
                
                ViewData["HeadTitle"] = "贷款管理";
                var model = _tradeOrderBiz.GetTradeOrderByNo(orderNo);
                return View(model);
            }


    做了个详细按钮  点开显示了列表   但没法传递参数 回后台 根据所选条数的orderNo列出数据,现在的orderNo被我写死了的 我DA层 写的是根据orderNo来查找数据的,这个orderNo要怎么传递到后台?
    ------解决思路----------------------
    $(grid_selector).jqGrid({
                datatype: "json",
                url: '/Loan/Index',
                mtype: 'POST',
    发生ajax请求的时候传参。请求到后台的时候传参。jqGrid我没有使用过。只能给你提供思路了!