2

Enter キーを押してグリッドに行を追加するコードを次に示します。すべての行は追加モード editrow=true です。

    jQuery("#energy").jqGrid('addRow', { position: "first" });
            jQuery("#energy").jqGrid('bindKeys', {
            "onEnter": function (rowid) {
                jQuery("#energy").jqGrid('addRow');
                    }
           });

行を追加するときに、そのパラメーター editrow=false を指定する必要があるのは何ですか?

4

1 に答える 1

1

Unfortunately it seems that the code for addRow always sets the new row to edit mode:

addRow : function ( p ) {
        ...
        if(p.useFormatter) {
            $("#"+$.jgrid.jqID(p.rowID)+
                              " .ui-inline-edit", 
                              "#"+$.jgrid.jqID($t.p.id)).click();
        } else {
            var opers = $t.p.prmNames,
            oper = opers.oper;
            p.addRowParams.extraparam[oper] = opers.addoper;
            $($t).jqGrid('editRow', p.rowID, p.addRowParams);
            $($t).jqGrid('setSelection', p.rowID);
        }

But the good news is that, you should be able to use saveRow to get the row out of edit mode. Just make sure you pass a unique row ID for the new row so that you are able to reference it in the next call:

 jQuery("#energy").jqGrid('addRow', {rowID: myNewRowID});
 jQuery("#energy").jqGrid('saveRow', myNewRowID);

If you have problems with saveRow, you can also try restoreRow.

Does that help?

于 2012-06-22T13:46:42.410 に答える