0

这是我的网格的定义:

$grid = $("#schedule");

var last_selected_row;
$grid.jqGrid({
    url:'xtras/schedule.php',
    editurl:'xtras/schedule.php',
    datatype: "json",
    mtype:'GET',
    colModel:[
        {name:'Date',index:'Street_Date', sorttype:"date", formatter:'date', formatoptions: {newformat:'d M y'}, 
        searchoptions: {sopt: ['eq','ne','lt','le','gt','ge'] , dataInit: function (elem) { $(elem).datepicker({  dateFormat: "yy-mm-dd'"  }) } }, width:60},


        {name:'Master by',index:'master_by', width:60, sortable:false,
            formatter: function(cellvalue, options, rowObject){
                        if(cellvalue == '0000-00-00'){
                            var rel_date = rowObject[0];
                            var parse_d = $.datepicker.parseDate("yy-mm-dd",  rel_date);
                            parse_d.setMonth(parse_d.getMonth()-2);
                            var new_d = $.datepicker.formatDate( "d M y", parse_d); 
                        } else {
                            var parse_d = $.datepicker.parseDate("yy-mm-dd",  cellvalue);
                            var new_d = $.datepicker.formatDate( "d M y", parse_d); 
                        }
                        return new_d;
                    },
            formatoptions: {newformat:'d M y'}, 
            edittype: 'text',
            editable:true , 
            editoptions: {size:9, 
                dataInit: function(el) { 
                    setTimeout(function() { 
                        $(el).datepicker({ 
                            dateFormat: "d M y'" 
                        }); 
                    }, 200); 
                } 
            } 
        },

        {name:'MO',index:'MO', width:30, align:"center", sortable:false, formatter: "checkbox", editable:true, edittype:'checkbox', editoptions: { value:"Yes:No" }}

    ],
    height: "100%",
    minWidth: 900,
    rowNum:15,
    rowList:[10,15,20,30,50,100],
    viewrecords: true,
    sortname:"ID",
    sortorder: "desc",
    pager: '#schedule_pager',
    caption:"Release Schedule",

    loadonce:false,
    ajaxGridOptions: {cache: false},

    grouping:true,
    groupingView : {
        groupField : ['Date'],
        groupColumnShow : [true],
        groupOrder: ['desc'],
        groupDataSorted : true
    },

    gridview: true,

    ondblClickRow: function (row_id) {
        if(row_id != null) {
            if(row_id !== last_selected_row) {jQuery('#schedule').jqGrid('restoreRow',last_selected_row);
                jQuery('#schedule').jqGrid('saveRow',row_id);
                jQuery("#schedule").jqGrid('editRow',row_id, true);
                last_selected_row = row_id; 
            } else {
                last_selected_row=row_id;
            }
        } 
    }
});

在此之后:

$grid.jqGrid('bindKeys', {
    onEnter: function(rowid) {
        editingRowId = rowid;

        $grid.jqGrid('editRow',rowid,true,null, {}, null, {},function(){
            setTimeout(function(){
                $grid.focus();
                $grid.trigger("reloadGrid");
            },100);
        });
    }
});

所以$grid.trigger("reloadGrid");永远不会触发....为什么是这种行为?以及如何解决?

4

1 回答 1

0

回到这个问题后,我以不同的方式解决了它:

我没有使用永远不会触发的“bindKeys”(在我的代码中),而是在行编辑中使用了成功函数:

ondblClickRow: function (row_id) {
        if(row_id != null) {
            if(row_id !== last_selected_row) {
                jQuery('#schedule').jqGrid('restoreRow',last_selected_row);
                jQuery('#schedule').jqGrid('saveRow',row_id);
                jQuery("#schedule").jqGrid('editRow',row_id, true, null, 
                    function(){ $("#schedule").trigger("reloadGrid", [{current: true}]); }, 
                    'xtras/schedule.php', 
                    null,{},{},{}
                );
                last_selected_row = row_id; 
            } else {
                last_selected_row=row_id;
            }
        } 
    }

这完美地重新加载了网格

于 2013-10-21T16:12:15.907 回答