jqGrid警告对话框 [英] jqGrid warning dialog

查看:183
本文介绍了jqGrid警告对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在jqGrid上有一些自定义工具栏按钮.其中之一取决于所选择的行,就像内置的编辑"和删除"按钮一样.当用户在未选择任何行的情况下单击它时,我希望向用户显示与内置的编辑"或删除"按钮所显示的警告对话框相同的警告对话框.也就是说,我想重用网格使用的对话框,该对话框显示:

I have some custom toolbar buttons on a jqGrid. One of them is dependent on a row being selected, just like the built in edit and delete buttons. When the user clicks on it with no row selected, I want the user to be presented with the same warning dialog they are presented with from the built in Edit or Delete buttons. That is, I want to reuse the dialog that the grid uses that says:

警告 请选择行

您知道网格从何处显示警报吗?

Any idea where the grid displays the alert from?

谢谢, 斯科特

推荐答案

我认为代码可能类似于以下内容

I think that the code could looks like the following

var alertIDs = {themodal: 'alertmod', modalhead: 'alerthd', modalcontent: 'alertcnt'};

$.jgrid.viewModal("#" + alertIDs.themodal,
    {gbox: "#gbox_" + $.jgrid.jqID(this.p.id), jqm: true});
$("#jqg_alrt").focus();

,其中this.p.id(或$.jgrid.jqID(this.p.id))可以替换为网格的ID.为了确保警报工作更加可靠,我建议您使用更长的代码

where this.p.id (or $.jgrid.jqID(this.p.id)) can be replaced to the id of the grid. To be more sure that the alert work I do recommend you to use more long code

var alertIDs = {themodal:'alertmod',modalhead:'alerthd',modalcontent:'alertcnt'};
if ($("#"+alertIDs.themodal).html() === null) {
    $.jgrid.createModal(alertIDs,"<div>"+$.jgrid.nav.alerttext+
        "</div><span tabindex='0'><span tabindex='-1' id='jqg_alrt'></span></span>",
        {gbox:"#gbox_"+$.jgrid.jqID(this.p.id),jqModal:true,drag:true,resize:true,
        caption:$.jgrid.nav.alertcap,
        top:100,left:100,width:200,height: 'auto',closeOnEscape:true,
        zIndex: null},"","",true);
}
$.jgrid.viewModal("#"+alertIDs.themodal,
    {gbox:"#gbox_"+$.jgrid.jqID(this.p.id),jqm:true});
$("#jqg_alrt").focus();

演示演示了代码.它显示消息

The demo demonstrate the code. It displays the message

每次单击"Click me!"按钮时.

更新:答案包含有关如何在免费的jqGrid .它描述了许多选项.最简单的版本仅包含一个简单的调用this.modalAlert();.它显示相同的警报对话框,免费的jqGrid会在内部显示.

UPDATED: The answer contains the information how one can use the above dialog in free jqGrid. It describes many option. The simplest version contains only one simple call this.modalAlert();. It displays the same alert dialog, which free jqGrid displays internally.

这篇关于jqGrid警告对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆