jqGrid内联导航器没有初始化

时间:2013-05-02 18:49:16

标签: javascript jquery jqgrid

我正在尝试在jqGrid上初始化内联导航器。使用版本4.4.0。代码:

$('#line-items-grid').jqGrid({
    caption      : '',
    width        : 704,
    shrinkToFit  : 1,
    forceFit     : true,
    scrollOffset : 0,
    url          : '',
    datatype     : 'local',
    rowNum       : 20,
    viewrecords  : true,
    height       : 'auto',
    gridview     : true,
    autoencode   : true,
    pager        : '#line-items-pager',
    colModel     : [
        {label: 'Commodity',  name: 'contract_material', sortable: false, width: 99, cellattr: word_wrap, editable: true,  classes: 'line-item-contract-material', edittype: "select"},
        {label: 'Date',       name: 'date',              sortable: false, width: 77, cellattr: word_wrap, editable: true,  classes: 'line-item-date', editoptions: {
            dataInit: function (el) {
                $(el).datepicker();
            }
        }},
        {label: 'Vendor',     name: 'vendor',            sortable: false, width: 95, cellattr: word_wrap, editable: true,  classes: 'line-item-vendor', editoptions: {maxlength: "50"}},
        {label: 'Ticket/PO#', name: 'ticket_po_num',     sortable: false, width: 66, cellattr: word_wrap, editable: true,  classes: 'line-item-ticket-po-num', editoptions: {maxlength: "50"}},
        {label: 'Lbs',        name: 'lbs',               sortable: false, width: 73, cellattr: word_wrap, editable: true,  classes: 'line-item-lbs'},
        {label: 'Units',      name: 'units',             sortable: false, width: 49, cellattr: word_wrap, editable: true,  classes: 'line-item-units'},
        {label: 'Rate/Ton',   name: 'rate_per_ton',      sortable: false, width: 64, cellattr: word_wrap, editable: true,  classes: 'line-item-rate-per-ton'},
        {label: 'Rate/Unit',  name: 'rate_per_unit',     sortable: false, width: 64, cellattr: word_wrap, editable: true,  classes: 'line-item-rate-per-unit'},
        {label: 'Total',      name: 'total',             sortable: false, width: 72, cellattr: word_wrap, editable: true, classes: 'line-item-total'}
    ],
    jsonReader   : {
        repeatitems: false
    },
    onSelectRow  : function (id) {
        if (id && id !== lastsel) {
            $('#line-items-grid').jqGrid('restoreRow', lastsel);
            $('#line-items-grid').jqGrid('editRow', id,
                {
                    keys: true,
                    extraparam: {
                        reporting_period_id: function () { return $('#reporting_period_filter').val(); },
                        pickup_id: function () { return $('#pickup_filter').val(); },
                        lbs_per_ton: function () { return material_lbs_per_ton[$('#line-items-grid tr#' + id).find('td.line-item-contract-material select').val()]; }
                    },
                    oneditfunc: lineItemEditPrep,
                    aftersavefunc: lineItemSuccess,
                    errorfunc: lineItemError,
                    afterrestorefunc: function () { $('.qtip').qtip('destroy'); },
                    restoreAfterError: false
                });
            //clear out error messages
            $('.qtip').qtip('destroy');

            lastsel = id;
        }
    },
    gridComplete : lineItemViewPrep,
    editurl      : "line_items/line_item_edit"
});
$('#line-items-grid').jqGrid('navGrid', '#line-items-pager', {
    add: false,
    edit: false,
    del: false
});
$('#line-items-grid').jqGrid('inlineNav', '#line-items-pager');

我显示了常规导航器(查看和刷新)的按钮,但没有内联导航器的按钮。我错过了什么?

(旁注,如果它是相关的:我在一个单独的函数上设置url和datatype选项,将数据加载到网格中。)

1 个答案:

答案 0 :(得分:2)

我建议你使用最新版本的jqGrid。它目前是4.4.5版。在jqGrid 4.4.0和4.4.5之间修复了很多错误。

您描述的问题已在jqGrid 4.4.1中得到修复。如果您确实需要使用旧的4.4.0,那么您应该在navButtonAdd方法中修复the linejquery.jqGrid.src.js中的行号为8796)

if( p.id && $("#"+$.jgrid.jqID(p.id), findnav).html() !== null )  {return;}

if( p.id && $("#"+$.jgrid.jqID(p.id), findnav)[0] !== undefined )  {return;}

your original demo的结果与the same code which used the described above fix进行比较。