1

我正在使用jqgrid数据json,格式如下
{"my_id" : 12345, "doc_number" : 9786}

我想使用一个 hlink 格式化程序,它显示doc_numbermy_id用作我的 Javascript 函数的参数。

my_idid用户不必知道的技术。他只需要知道doc_number

我怎样才能做到这一点?

4

2 回答 2

0

这是示例 colModel 配置

colModel: [ {name:'myname', 
             edittype:'select', 
             formatter:'showlink', 
             formatoptions:{baseLinkUrl:'someurl.php', addParam: '&action=edit'}
于 2012-09-11T09:37:50.363 回答
0
function FilterData() {
    jQuery("#grid").jqGrid('setGridParam', { page: 1 });
    jQuery("#grid").trigger("reloadGrid");
}
function drawHyperLink(cellvalue, options, rowObject) {

    var new_formatted_cellvalue = "";
         new_formatted_cellvalue = "<a class='green'  href='Make_A_Bid?xyzparam=" + rowObject.my_id + "'>doc_number</a>";
         return new_formatted_cellvalue;
}

$(document).ready(function () {
    var grid_width = ($("#Div_IntradayStatus").width() * 90) / 100;

    $('#grid').jqGrid({
        colNames: [doc_number],
        colModel: [

                    { name: 'doc_number', index: 'doc_number', formatter: drawHyperLink }
                  ],
        pager: jQuery('#pager'),
        sortname: 'doc_number',
        rowNum: 20,
        rowList: [5, 10, 20, 50],
        sortorder: "desc",
        width: grid_width,
        height: 'auto',
        datatype: 'json',
        caption: '&nbsp;',
        viewrecords: true,
        mtype: 'POST',
        jsonReader: {
            root: "rows",
            page: "page",
            total: "total",
            records: "records",
            repeatitems: false,
            userdata: "doc_number"
        },
        //or ondblClickRow
        onSelectRow: function (id) {
            var row = $('#grid').getRowData(id);
        },
        onPaging: function (pgButton) {
            // if user has entered page number
            if (pgButton == "user") {
                // find out the requested and last page
                var requestedPage = $("#grid").getGridParam("page");
                var lastPage = $("#grid").getGridParam("lastpage");
                // if the requested page is higher than the last page value 
                if (parseInt(requestedPage) > parseInt(lastPage)) {
                    // set the requested page to the last page value – then reload
                    $("#grid").setGridParam({ page: lastPage }).trigger("reloadGrid");
                }
            }
        },
        url: your url
    })

    jQuery("#grid").jqGrid('navGrid', '#pager', { edit: false, add: false, del: false, search: false, refresh: false });
});

你必须做这样的事情

于 2012-09-11T09:39:26.523 回答