使用Jqgrid中的viewModal函数的警报消息 [英] Alert message using viewModal function in Jqgrid
问题描述
我正在尝试使用jqgrid和自定义导航来实现简单的警报消息.屁股 我要做的就是单击按钮时,如果没有选择任何行,它会显示一条警报(就像已经可以使用的默认按钮一样).
I'm trying to implement a simple alert message using jqgrid and a custom nav. buttom. All I wanted to do is when the button is clicked, it shows an alert if no row is selected(just like the default buttons that already work).
这是代码:
onClickButton : function () {
var line = $('#grid-list').jqGrid('getGridParam', 'selrow');
var grid = $('#grid-list');
var grid_id = grid[0].id;
if ( !line ) {
$.jgrid.viewModal("#alertmod",{gbox:"#gbox_"+grid_id,jqm:true});
$("#jqg_alrt").focus();
}
else {
有什么建议吗? 非常感谢.
Any suggestion?? thanks a lot.
推荐答案
代码中的主要错误是使用"#alertmod"
而不是"#alertmod_grid-list"
,其中grid-list
是网格的ID.
The main error in your code is the usage of "#alertmod"
instead of "#alertmod_grid-list"
where grid-list
is the id of the grid.
演示演示了固定代码.它使用以下onClickButton
回调代码:
The demo demonstrate the fixed code. It uses the following code of onClickButton
callback:
onClickButton: function () {
var idSelector = "#alertmod_" + this.p.id;
$.jgrid.viewModal(idSelector, {
gbox: "#gbox_" + $.jgrid.jqID(this.p.id),
jqm: true
});
$(idSelector).position({
of: "#" + $.jgrid.jqID(this.p.id),
at: "center",
my: "center"
});
$(idSelector).find(".ui-jqdialog-titlebar-close").focus();
}
在上面的代码中,我另外更改了警告的位置并更改了焦点,以便可以通过按 Enter 键(如
In the above code I changed position of the Warning additionally and changed the focus so that one can close the box by pressing of Enter key (like described in the answer).
这篇关于使用Jqgrid中的viewModal函数的警报消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!