jqGrid的自定义按钮发送POST数据 [英] Jqgrid custom button sending POST data

查看:1039
本文介绍了jqGrid的自定义按钮发送POST数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用茨艾伦code:

     jQuery("#rowed2").jqGrid({        
    url:'server.php?q=3',
    datatype: "json",
        colNames:['Acc','Id','Ciudad', 'Corporacion','Radicado','Ultima Actuacion','Anotaciones'],
    colModel:[
    {name:'act',index:'act', width:72,  sortable:false},
    {name:'id',index:'id', width:31},
    {name:'ciudadh',index:'ciudadh', width:100, editable:true},
    {name:'corporacionh',index:'corporacionh', width:350, align:"right",editable:true,fixed:true },
    {name:'radicado',index:'radicado', width:190, align:"right",editable:true},     
    {name:'ultima',index:'ultima', width:160,align:"right",editable:true},      
    {name:'anotaciones',index:'anotaciones', width:200, sortable:false,editable:true}   
    ],


    rowNum:200,
    rowList:[10,20,30],
    imgpath: 'css',
    pager: jQuery('#prowed2'),
    sortname: 'actionID',
viewrecords: true,

sortorder: "desc",
height: "100%",


    loadComplete: function(){
    $("tr.jqgrow:odd").addClass('myAltRowClass');
            var ids = jQuery("#rowed2").getDataIDs();
            for(var i=0;i<ids.length;i++){
                    var cl = ids[i];
                    be = "<input style='height:20px;width:70px;' type='button' value='Modificar' onclick=jQuery('#rowed2').editRow("+cl+"); /><br>"; 
                    se = "<input style='height:20px;width:70px;' type='button' value='Guardar' onclick=jQuery('#rowed2').saveRow("+cl+"); /><br>"; 
                    ce = "<input style='height:20px;width:70px;' type='button' value='Cancelar' onclick=jQuery('#rowed2').restoreRow("+cl+"); />"; 

            send = "<input class='sendbuttons' id='tbuttonSend"+cl+"' type='button' value='Send' /><br />";
    clear = "<input class='sendbuttons' id='tbuttonClear"+cl+"' type='button' value='Send' /><br />";

            jQuery("#rowed2").setRowData(ids[i],{act:be+se+ce,anotaciones:send+clear})
            }    






             $(".sendbuttons").click(function(){
    alert("got to 1");
  });



    },


    editurl: "server2.php"
     });


   //botonañadir
   $("#bedata").click(function(){
jQuery("#rowed2").jqGrid('editGridRow',"new",{height:380,reloadAfterSubmit:false});
});

//botonborrar
$("#bedata2").click(function(){
var gr = jQuery("#rowed2").jqGrid('getGridParam','selrow');
if( gr != null ) jQuery("#rowed2").jqGrid('delGridRow',gr, {reloadAfterSubmit:false});
else alert("Antes de hacer clic en este boton seleccione el proceso que desea borrar!");
      });

    var timeoutHnd;
    var flAuto = false;

     function doSearch(ev){
if(!flAuto)
    return;
    //  var elem = ev.target||ev.srcElement;
if(timeoutHnd)
    clearTimeout(timeoutHnd)
timeoutHnd = setTimeout(gridReload,500)
    }

      function gridReload(){
var nm_mask = jQuery("#item").val();
var cd_mask = jQuery("#search_cd").val();
jQuery("#rowed2").jqGrid('setGridParam',{url:"server.php? nm_mask="+nm_mask+"&cd_mask="+cd_mask,page:1}).trigger("reloadGrid");
     }
      function enableAutosubmit(state){
flAuto = state;
jQuery("#submitButton").attr("disabled",state);
   }

所以,我认为这个按钮

So I that this button

     send = "<input class='sendbuttons' id='tbuttonSend"+cl+"' type='button' value='Send' /><br />";  

可以通过邮寄的一些数据只是这样做的按钮:

can send some data via post just like this buttons do:

  be = "<input style='height:20px;width:70px;' type='button' value='Modificar'        onclick=jQuery('#rowed2').editRow("+cl+"); /><br>"; 
                se = "<input style='height:20px;width:70px;' type='button'  value='Guardar' onclick=jQuery('#rowed2').saveRow("+cl+"); /><br>"; 
                ce = "<input style='height:20px;width:70px;' type='button' value='Cancelar' onclick=jQuery('#rowed2').restoreRow("+cl+"); />"; 

例如我的自定义按钮,可以发送和奥珀称为定制与其他的参数。

For example my custom button could send and opper called "custom" with the other parameters.

这可能吗?怎么样?

感谢您的帮助。

更新:

我想做一个像这样的AJAX功能:

i'm trying to do an ajax function like this:

      $(".sendbuttons").click(function(){
        $.ajax({
        type:'POST',
        url :'server2.php?id=+ids[i]+&oper=edit1',
        beforeSend : function(){
    $('#mensaje5').show().html('<br><br><h2>Por favor espere....<br><img src="c.gif" width="100" height="100" alt="cargando" border="0">');

        },
        success: function (){
         var nancu = parseInt(ids);
            alert(mega);
                ;

        },
        complete: function(){
     $('#form_data4').slideUp();

                }

    });



             });

看来我需要一个伟大的想法,但我有这行的一个问题:

It seems a great idea for my needs but I have a problem with this line:

          url :'server2.php?id=+ids[i]+&oper=edit1',

我想获得该按钮行的id,然后通过邮寄的网址发送此ID,但我不知道我怎么能做到这一点。

I want to obtain the id of the button row and then send this id in the url via post but I don't know how I can do that.

推荐答案

试试这个

更改此发送=&LT;输入类='sendbuttons'ID ='tbuttonSend+ CL +类型=按钮值=发送/&GT;&LT; BR /&GT;

send = "<input class='sendbuttons' id='tbuttonSend"+cl+"' onclick='send("+cl+");' type='button' value='Send' /><br />";

和添加新的功能,出边jQuery的主要功能

and add a new function out side Jquery main function

' function send(id)     $.ajax({
    type:'POST',
    url :'server2.php?id='+id+'&oper=edit1',
    beforeSend : function(){
$('#mensaje5').show().html('<br><br><h2>Por favor espere....<br><img src="c.gif" width="100" height="100" alt="cargando" border="0">');

    },
    success: function (){
     var nancu = parseInt(ids);
        alert(mega);
            ;

    },
    complete: function(){
 $('#form_data4').slideUp();

            }

});}'

这篇关于jqGrid的自定义按钮发送POST数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆