jqGrid函数未定义 - editRow和saveRow无法正常工作

时间:2014-10-24 15:24:51

标签: javascript jquery jqgrid flask

真的认为这是一个简单的修复方法,但在尝试了其他解决方案后,我没有运气。

每次选择或双击一行时,我都会得到一个未定义的函数,并且每个函数都会在jqGrid中触发。代码和html标题如下。事件触发时,onSelectRow和ondblClickRow出错。

错误输出: enter image description here enter image description here

标题加载顺序:

<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://trirand.com/blog/jqgrid/js/i18n/grid.locale-en.js" type="text/javascript"></script>
<script src="http://trirand.com/blog/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" media="screen" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/themes/base/jquery-ui.css" />
<link rel="stylesheet" type="text/css" media="screen" href="http://trirand.com/blog/jqgrid/themes/ui.jqgrid.css" />

jqGrid的JS代码:

var lastSel;

editParams = {
    "successfunc": null,
    "url": '/submit/adjustments',
    "extraparam": {
        UserAdj: function() {
            var sel_id = $('#rowed1').jqGrid('getGridParam', 'selrow');
            var value = $('#rowed1').jqGrid('getCell', sel_id, 'user_adj_order');
            return 'test';
        },
        arg1 : 'test_it_out'
    },
    "aftersavefunc": null,
    "errorfunc": null,
    "afterrestorefunc": null,
    "mtype" : "POST"
}

jQuery("#rowed1").jqGrid({
    url: base_url + 'get/101/items',
    datatype: "json",
    jsonReader: {
        root: function (obj) { return obj.items; },
        id: 'id',
        page: function () { return 1; },
        total: function () { return 1; },
        records: function (obj) { return obj.items.length; },
    },
    loadonce: true,
    colNames:['Vendor', 'Name', 'Price', 'Last Cost', 'Qty OH', 'Qty OO', 'Wks Selling', 'Str Velocity', 'Fleet Velocity', 'Reccomended Buy', 'User Adjustment'],
    colModel:[
        {name: 'vendor_name'},
        {name: 'name'},
        {name: 'price'},
        {name: 'cost'},
        {name: 'qty_OH', sorttype:'int'},
        {name: 'qty_OO', sorttype:'int'},
        {name: 'str_wks_selling', sorttype:'int'},
        {name: 'velocity', sorttype:'int'},
        {name: 'flt_five_wk_vel', sorttype: 'int'},
        {name: 'rec_buy', sorttype: 'int'},
        {name: 'user_adj_order', editable: true}
    ],
    onSelectRow: function(id){
         if(id && id!==lastSel){ 
            $('#rowed1').jqGrid('saveRow', lastSel, editParams);
            lastSel=id; 
         }
       },
    ondblClickRow: function(id) {
        $('#rowed1').jqGrid('editRow', id, true, editParams); 
    },
    rowNum:10,
    rowList:[10,20,30],
    pager: '#prowed1',
    sortname: 'name',
    viewrecords: true,
    sortorder: "desc",
    autowidth: true,
    height: '100%',
    gridView: true,
    'cellSubmit': 'remote',
    editurl: '/submit/adjustments',
    cellurl: '/submit/adjustments'
});

1 个答案:

答案 0 :(得分:0)

您是否尝试过清除缓存?如果是,但它仍然无法正常工作,请您发布完整的HTML代码。假设JS代码在一个单独的JS文件中。