0

jqGrid 工具栏和内联删除按钮用于删除行。

在删除命令删除对话框出现。确认或取消删除后,网格将不会获得焦点。需要在网格中单击鼠标才能使键盘导航在网格中工作。

删除后如何将焦点设置为网格,或者如果删除被取消,则不需要额外的鼠标单击?

工具栏中的删除按钮:

        $.extend($.jgrid.del, {
            top: window.innerHeight/2-100,  
            left: window.innerWidth/2-120,
            closeOnEscape: true,
            errorTextFormat: function (response) { 
              clearModeless();
              return decodeErrorMessage(response.responseText, '', '');
              },
            reloadAfterSubmit: false,
            afterShowForm: function($form) {
                var form = $form.parent()[0];

                $("#dData",form).attr("tabindex","1000");
                $("#eData",form).attr("tabindex","1001");
                setTimeout(function() {
                    $("#dData",form).focus(); 
                },50);
            }
           });


           $grid.jqGrid("navGrid", "#grid_toppager", { 

            search:  true,
            del: true,
            add: true,
            view: true,
            edit: true
          }, 

          {       url: '/erp/Grid/Edit?_entity=Klient'},

       {        url: '/erp/Grid/Add?_entity=Klient' },

        { url: '/erp/Grid/Delete?_entity=Klient',

          beforeShowForm: function(form) {
            var selected = $grid.jqGrid('getGridParam','selarrrow');
            $("td.delmsg",form).html( 'Rows '+selected.length +'<br/>' +
                 'Delete?' );
            }
        }
);

列中的删除按钮:'

             colModel: [{"name":"_actions","formatter":"actions","viewable":false,"formatoptions":{"editbutton":true,"keys":true,"onSuccess":function (jqXHR) { jqXHRFromOnSuccess=jqXHR;return true;}
,"afterSave":function (rowId) {
  var data = $.parseJSON(jqXHRFromOnSuccess.responseText);
$grid.jqGrid('setRowData', rowId, { Kood: data.PrimaryKeyValues[0] }); 
cancelEditing($grid);afterGridSaveFunc(rowId,jqXHRFromOnSuccess);jqXHRFromOnSuccess=null; 
updateButtonState($grid);
}
,"restoreAfterError":false,"onError":errorfunc
,"extraparam":{"_dokdata":FormData
},"afterRestore":function () {
          updateButtonState($grid);
        }
,"onEdit":onInlineEdit
,"delbutton":true,"delOptions":{"url":"Delete","afterComplete":function (response, postdata, formid) { summarefresh($grid); }
}}},
4

1 回答 1

1

在我看来,您应该将焦点设置为网格或afterComplete. 你使用reloadAfterSubmit: false所以我认为在这里设置焦点没有问题。目前您调用summarefresh函数。调用后可以直接设置焦点summarefresh

于 2012-04-07T21:10:27.997 回答