阻止在添加按钮上单击打开表单 [英] Preventing the opening of a form on a add button click

查看:95
本文介绍了阻止在添加按钮上单击打开表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我单击添加按钮时,你们是否知道如何防止打开表单?

Did you guys know how to prevent the open of a Form when I click on a add button?

也许正在使用beforeShowForm?

Maybe using beforeShowForm?

function(formid)
{
    if(jQuery('#gridap').getGridParam('selrow'))
    {

        idgridap=jQuery('#gridap').getGridParam('selrow');
        jQuery('#FK_numerocontrato_ap',formid).val(idgridap).attr('readonly','readonly');

    }
    else 
    {
         // I want to prevent the openning of the add form here and maybe show an alert using the "alertcap"

    }
}
CHECAROW;

$grid->setNavEvent('add','beforeShowForm',$checarowid);

顺便说一句,有一种方法可以调用jqgrid的alertmod并向其中添加自定义消息吗?

BTW, there's a way to call the alertmod of jqgrid and add a custom message to it?

tks!

推荐答案

我不明白为什么您不只是从导航栏中删除添加"按钮.要创建导航栏,请显式调用jqGrid的navGrid方法

I don't understand why you not just remove "Add" button from the navigation bar. To create a navigation bar you explicitly call navGrid method of jqGrid

jQuery("#grid_id").navGrid('#gridpager'); 

jQuery("#grid_id").jqGrid('navGrid', '#gridpager');

navGrid具有其他参数(请参见 http://www.trirand.com/jqgridwiki/doku.php?id=wiki:navigator ).因此,如果您使用

but navGrid has additional parameters (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:navigator). So if you use

jQuery("#grid_id").navGrid('#gridpager', {add: false}); 

您将没有添加"按钮.

如果您确实需要添加"按钮,请更清楚地说明您的情况.用 http://www.trirand中描述的方式进行. com/jqgridwiki/doku.php?id = wiki:custom_buttons ,您可以从侧面添加具有完全控制权的自定义按钮.您可以在页面 http://jqueryui.com/themeroller/上找到的图标名称将光标放在页面底部框架图标"区域上的图标上.自定义按钮可以具有与添加"按钮相同的图标.能解决您的问题吗?

If you do need have "Add" button, please explain your situation more clear. By the way with the way described in http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_buttons you can add an custom button with full control from your side. The name of icon you can find on the page http://jqueryui.com/themeroller/ if you place a cursor over the icon on the "Framework Icons" area on the bottom of the page. The custom button can have the same icon as the "Add" button has. Can it solve your problem?

更新:现在,在您发表评论后,我明白了您的问题.我可以建议使用navGridaddfunc选项(请参见

UPDATED: Now after your comment I understand your problem. I can suggest to use addfunc option of navGrid (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:navigator&s[]=navgrid). So the code could looks like following:

var grid = jQuery("#grid_id").navGrid('#gridpager', {addfunc: function() {
    var sel_id = grid.getGridParam('selrow');
    if (sel_id) {
        grid.editGridRow("new", pAddOption);
    } else {
        viewModal("#alertmod", { gbox: "#gbox_" + grid_id, jqm: true });
        jQuery("#jqg_alrt").focus();
    }
}});

在本实施例中将被允许点击添加"仅当行被选中按钮.您将看到一个消息框,其中包含请选择行"之类的文本(在 grid.locale-en.js 或您使用的其他本​​地化文件中定义$.jgrid.nav.alerttext的文本).您可以将此代码片段放置在主网格中.

In this example will be allowed to click "Add" button only if a row is selected. You will see a message box with the text like "Please, select row" (the text which defines $.jgrid.nav.alerttext inside of grid.locale-en.js or other localization file which you use). You can place this code fragment in your master grid.

在拒绝添加"操作的情况下的代码会更容易,我在这里只复制了一个使用jqGrid本身的代码片段.您可以改为显示自定义错误消息.

The code in case of denying of "Add" operation can be easier, I just copied here a code fragment which use jqGrid itself. You can display your custom error message instead.

这篇关于阻止在添加按钮上单击打开表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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