jQuery模态对话框和jqGrid [英] jQuery modal dialog and jqGrid
问题描述
如何在jqGrid中使用Jquery模式确认?说我将提交条目时,将弹出一个模式对话框,并显示名称和消息以发送到服务器.
How can I use the Jquery modal confirmation with jqGrid? Say when I will submit my entries it will pop up a modal dialog and display the names with the message for sending to server..
我的方法
$("#dialog-confirm").dialog({
autoOpen:false,
resizable:false,
height:180,
modal:true,
buttons:{
'Confirm': function(){
var ids =jQuery("#list10").jqGrid('getGridParam','selarrrow');
$.ajax({
type: "POST",
url: "url&names="+ids,
data: JSON.stringify(ids),
dataType: "json"
});
},
'cancel': function(){
$(this).dialog('close');
}
}
});
});
我的html:
<div id="dialog-confirm" title="Confirm">
<p><span class="ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span>Are you sure want to cancel(or send this names)#names?</p>
</div>
在该对话框中,我也需要发送这些名称...但是这种方法不会为我提供我选择发送到服务器的网格中的名称.
In that dialog box I need to send those names as well... but this approach will not give me the names from my grid which I selected to send it to server.
推荐答案
以下代码可以满足您的需求
The following code could do what you need
$("#wics").click( function(){
var grid = jQuery("#list10");
var ids = grid.jqGrid('getGridParam','selarrrow');
if (ids.length>0) {
var names = [];
for (var i=0, il=ids.length; i < il; i++) {
var name = grid.jqGrid('getCell', ids[i], 'Name');
names.push(name);
}
//alert ("Names: " + names.join(", ") + "; ids: " + ids.join(", "));
$("#names").html(names.join(", "));
$("#dialog-confirm").dialog({
height:280,
modal:true,
buttons:{
'Cancel': function(){
$(this).dialog('close');
},
'Confirm': function(){
//alert("Confirm");
$.ajax({
type: "POST",
url: "/cpsb/unprocessedOrders.do",
data: { method: "releaseTowics",
orderNum: JSON.stringify(ids),
names: JSON.stringify(names)
},
dataType: "json",
success: function(msg){
alert(msg);
},
error: function(res, status, exeption) {
alert(res);
}
});
}
}
});
}
});
确切的原因解决方案将取决于您对服务器端的要求.您可以在此处 http://www.ok- soft-gmbh.com/jqGrid/DataToMultiSelect2.htm .选择一些项目,然后单击获取所选"按钮.
The exact solution of cause will depends on your requirement on the server side. You can try this (without ajax request) here http://www.ok-soft-gmbh.com/jqGrid/DataToMultiSelect2.htm. Select some items and click "Get Selected" button.
这篇关于jQuery模态对话框和jqGrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!