jQuery 模式对话框和 jqGrid

发布于 2024-09-16 04:23:56 字数 1252 浏览 1 评论 0原文

如何将 Jquery 模态确认与 jqGrid 一起使用?假设当我提交我的条目时,它将弹出一个模式对话框并显示名称以及发送到服务器的消息。

我的方法是

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

在该对话框中我也需要发送这些名称...但是这种方法不会给我我选择将其发送到服务器的网格中的名称。

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..

My approach

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

my 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

七分※倦醒 2024-09-23 04:23:56

以下代码可以满足您的需要

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

。具体原因的解决方案取决于您对服务器端的要求。您可以在此处尝试此操作(无需ajax请求) http://www.ok- soft-gmbh.com/jqGrid/DataToMultiSelect2.htm。选择一些项目并单击“获取选择”按钮。

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);
                        }
                    });
                }
            }
        });
    }
});

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. 

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文