jqgrid Uncaught TypeError:无法读取未定义的属性'stype'

时间:2013-09-06 22:40:53

标签: c# jquery json jqgrid-asp.net

设置:jqGrid 4.4.1

我有一个永远工作的网格。有些东西发生了变化,数据将不再显示在网格中。网格加载,但坚持“正在加载......”通知。

错误信息是:

Uncaught TypeError: Cannot read property 'stype' of undefined (jquery.jqGrid.src.js:1599)
$.fn.jqGrid.each.addLocalData         jquery.jqGrid.src.js:1599
$.fn.jqGrid.each.populate             jquery.jqGrid.src.js:1853
(anonymous function)                  jquery.jqGrid.src.js:2467
f.event.dispatch                                jquery.min.js:3
f.event.add.h.handle.i                          jquery.min.js:3
f.event.trigger                                 jquery.min.js:3
(anonymous function)                            jquery.min.js:3
e.extend.each                                   jquery.min.js:2
e.fn.e.each                                     jquery.min.js:2
f.fn.extend.trigger                             jquery.min.js:3
$gridManager.addColumnNameToGroupHead         gridManager.js:81
$gridManager.setGridOptions                   gridManager.js:28
$order.showOrders                                 orders.js:112
$.ajax.success                                    orders.js:145
f.Callbacks.o                                   jquery.min.js:2
f.Callbacks.p.fireWith                          jquery.min.js:2
w                                               jquery.min.js:4
f.support.ajax.f.ajaxTransport.send.d           jquery.min.js:4

据我所知,json字符串有效且正确,数据(和列名称)匹配,并且所有stype值都有效。

var searchResultGrid = jQuery("#orderStatus").jqGrid({
        datatype: "jsonstring",
        datastr: orderData,
        jsonReader: { root: 'rows', total: 'total', page: 'page', records: 'records', repeatitems: false, id: 'id' },
        colNames: colNames,
        colModel: colModel,
        rowNum: 5000,
        height: $(window).height() - 205,
        width: $(window).width()-29,
        pagination: true,
        pager: '#orderStatusPager',
        viewrecords: true,
        sortname: 'status',
        sortorder: 'desc',
        loadonce: true,
        sortable: true,
        ignoreCase: true,
        emptyDataText: "No orders found",
        grouping: true,
        groupingView: groupingView,
        onSelectRow: function (rowId, status) {
            {REMOVED FOR CLARITY}
        },
        loadComplete: function () {
            jQuery("#orderStatus").trigger("reloadGrid"); // Call to fix client-side sorting
            $gridManager.setGroupingDd("orderStatus", "orderStatusPager", groupCol, ["part_no", "Descript"], "status");
            if (orderId) {
                jQuery("#orderStatus").setSelection(orderId, true);
            }
        },
        resizeStop: function () { $gridManager.updateGrid("orderStatus", "orderStatusPager"); }
    });

如果它们与发现问题相关,我可以提供colNames和colModel。

这会导致什么?或者,我该如何找到原因?

更新

以下是groupingView

的定义

groupingView = { groupField: [groupCol], groupColumnShow: [$gridManager.isColumnVisible(groupCol)], groupText: ['<b>{0} - {1} Order(s)</b>'], groupCollapse: false, groupOrder: ['desc'] };

我可以看到groupCol的值为clear,而不是json字符串中的列。

1 个答案:

答案 0 :(得分:7)

我遇到了类似的问题,发现了分组问题。您没有提供有关'groupingView'定义的详细信息,但请先检查。

您不应尝试将不在数据中的列分组。如果列名称不存在,请将其删除,或删除分组。