Jquery Jqgrid自定义按钮在导航寻呼机中创建自定义对话框

Jquery Jqgrid自定义按钮在导航寻呼机中创建自定义对话框,jquery,jqgrid,Jquery,Jqgrid,我试图在Jqgrid中的导航栏中编写一个自定义按钮(我是Jqgrid新手)。它的功能很简单。。。根据所选行,它必须从服务器获取一些信息,然后打开一个包含所请求信息的对话框 我们开始: .navButtonAdd('#pager-list',{ caption: "", title: "View products", buttonicon:"ui-icon-clock", onC

我试图在Jqgrid中的导航栏中编写一个自定义按钮(我是Jqgrid新手)。它的功能很简单。。。根据所选行,它必须从服务器获取一些信息,然后打开一个包含所请求信息的对话框

我们开始:

           .navButtonAdd('#pager-list',{
            caption: "",
            title: "View products", 
            buttonicon:"ui-icon-clock",
            onClickButton : function () { 

                    var line = $('#grid-list').jqGrid('getGridParam', 'selrow');
                    if ( line == null ) {
                        alert("please select a row!");
                    }
                    else {

                        $.get('products.php', { rowSel: line }, function ( data ) {






      I want to implement a dialog that will open and set something(using the JSON response from server DATA). 
         like this very simple:
    Product ID: data[0].pID;
    Product Name: data[0].pName;
    Product Price: data[0].pPrice;

and a close button.


                         });

                   }


            },
我已经看到了几个例子,但我只是感到困惑。有谁能帮我做这个编码吗。。。提前谢谢

更新…我这样解决:

else {



                        $.get('products.php', { rowSel: line },
                       function ( data ) {

                        $.jgrid.info_dialog('Review Products',data, $.jgrid.edit.bClose,{buttonalign:'center', width:'auto',resize: true , align: 'left'});


                        });
所有的数据操作都是在服务器端完成的


谢谢

不久前我遇到了同样的情况,我想添加一个按钮,以csv格式从jqgrid下载所选行。但是我发现在网格外放置一个按钮并向服务器发出ajax请求并获得结果要容易得多。实际上,在我的例子中,这是一个同步调用。无论如何,这是我使用的代码。我不是说这是不可能的,但这取决于你的项目限制…:

    function x() {

     var obj = jQuery("input:checked").map(function() { return jQuery(this).parents('tr').attr('id'); });

    var result = null;
    var arr = jQuery.makeArray(obj);
    var data = arr.join(',');

   $.ajax({
     url : '<%= url_for :controller => "products", :action =>"export_to_csv" %>',
         type : 'POST',
     data : {data:data},
     dataType : 'string',
         async: false,
         success : function(response) { result = response; }
     }); 

    window.open('data:text/csv;charset=utf-8,' + escape(result));

     };

    <%= jqgrid("List of products: you can filter (using the lens icon in the bottom of the grid), sort (clicking on the header column), scroll the data in the grid (using the pagination system)", "gbgrid", products_path,
  [{ :field => "id"},{ :field => "act"},{ :field => "code"}]
      }) %>
函数x(){
var obj=jQuery(“input:checked”).map(函数(){return jQuery(this).parents('tr').attr('id');});
var结果=null;
var arr=jQuery.makeArray(obj);
var data=arr.join(',');
$.ajax({
url:“‘产品’,:action=>“将_导出到_csv”%>”,
键入:“POST”,
数据:{data:data},
数据类型:“字符串”,
async:false,
成功:函数(响应){result=response;}
}); 
window.open('data:text/csv;charset=utf-8,'+转义(结果));
};
“id”},{:field=>“act”},{:field=>“code”}]
}) %>

我不知道LuferBRA上的代码,但我在JQgrid上遇到了同样的问题,我对AJAx请求有疑问……我想同步请求就是解决方案。塔克斯库马尔