jQuerymodal dialog和jqGrid

我如何使用jqGrid的JQuery模式确认? 说什么时候我会提交我的条目,它会popup一个模式对话框,并显示名称与消息发送到服务器..

我的方法

$("#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> 

在那个对话框中,我也需要发送这些名字……但是这种方法不会给我从我select发送给服务器的网格中的名字。

下面的代码可以做你所需要的

 $("#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); } }); } } }); } }); 

原因的确切解决scheme取决于您在服务器端的要求。 你可以在这里试试(没有ajax请求) http://www.ok-soft-gmbh.com/jqGrid/DataToMultiSelect2.htm 。 select一些项目,然后单击“获取选定”button。