jqGrid - URL empty on second trigger reload

时间:2016-08-31 18:38:29

标签: jquery jqgrid

jqGrid - grid populates just fine using external textfield search. If I go to another page then come back and refire the search, the url is not passed in, so no call is made.

In the jqgrid scrfipt at line 2563, the ts.p.url is empty. But my code provides a url in the reloadgrid code. The reload works the first time through, but not the second.

            case "script":
                $.ajax($.extend({
                    url:ts.p.url,
                    type:ts.p.mtype,
                    dataType: dt ,

Grid code:

$("#orchard-grid").jqGrid({
    styleUI: "Bootstrap",
    datatype: 'json',
    colNames: ['Tree Id', "Orchard Name", 'Row', 'Column', 'GID', 'Clone', 'Status'],
    colModel: [
            { name: "TreeId", key: true, hidden: true },
            { name: "OrchardName", search: true },
            { name: "GridRow", search: false },
            { name: "GridColumn", search: false },
            { name: "GID", search: true },
            { name: "Clone", search: true },
            { name: "LocationStatus", search: false}
    ],
    loadonce: false,
    height: 400,
    autowidth: true,
    rowNum: -1,
    ajaxGridOptions: { cache: false},
    onSelectRow: function (id) {
        EditRow(id);
    }
});

This is the function that just stops without triggering:

$(document).ready(function () {
var gid = $("#gidNumber").val();
var orchard = $("#OrchardSelect").val();
var url = $("#GridUrl").val();

if (gid !== "" ) {
    $("#orchard-grid").jqGrid('setGridParam', {
        dataType: "json", 
        url: url,
        postData: {
            gidNumber: gid
        }
    }).trigger('reloadGrid');
}

if (orchard !== "") {
    $("#orchard-grid").jqGrid('setGridParam', {
        dataType: "json", 
        url: url,
        postData: {
            orchardSelect: orchard
        }
    }).trigger('reloadGrid');
}
});

2 个答案:

答案 0 :(得分:0)

当我尝试填充网格时,原来没有加载网格。我通过在网格的loadComplete事件中移动重载函数来修复它,因此网格将在被要求重新加载之前完成渲染。

答案 1 :(得分:0)

$("#Tab1").click( function(){ 

 var gridArrayData = [];
   var ids =jQuery("#jqGrid").jqGrid('getGridParam','selarrrow'); 
   var totalRowsCount = ids.length;
   if(totalRowsCount>0)
  {
   $.ajax({ 
     type: "POST", 
     url: 'Operaciones_Grilla.php?Op=30'+'&Filtro='+ids+'&page=1&rows=10', 
     dataType: "json",
     success: function(data) {
		$("#jqGrid2")[0].grid.beginReq();
     	var data = data.rows;
		var ii =0;
        for(var i in data)
               {
						
						
						gridArrayData.push({
                                id: data[i].id,
                                sistema: data[i].des_sistema,
                                opcion: data[i].des_opciones_sistema,
								id_sistema:data[i].id_sistema,
								id_opcion:data[i].id
								
                            });                            
                }// cierra el for each
					  jQuery('#jqGrid2').jqGrid('clearGridData')
                     .jqGrid('setGridParam', {data: gridArrayData})
                     .trigger('reloadGrid');
					
						$("#jqGrid2")[0].grid.endReq();
						$("#jqGrid2").trigger('reloadGrid');
		       }
           }); 
						   $('#tabs a[href="#tabs-2"]').trigger('click');	
						   }else{
							  alert('debe escoger un registro') ;
					}// cierra el íf que cuenta el numero de registros
	});










//*************** PHP CODE ************************//


Operaciones_Grilla.php?Op=30 call this function :

 public function Sube_Data_Grid_Perfiles22($page,$rows,$filtro)
	  {
	   
		 $respuesta = new stdClass();
	     $this->page =$page;
		 $this->limit=$rows;
		 $sql="";
		 $sql='select count(a.*) from opciones_sistema a where a.id_opciones_sistema in  '."(".$filtro.")";
   
         $count = $this->dbh2->query($sql)->fetchColumn();
		 if( $count >0 ) {
	                $total_pages = ceil($count/$this->limit);
               } else {
	                $total_pages = 0;
               }
              if ($this->page > $total_pages)$this->page=$total_pages;
		     
             $start = $this->limit*$page - $this->limit; 
           $i=0;

           $Sql='select a.id_opciones_sistema, b.des_sistema,a.des_opciones_sistema, b.id_sistema from opciones_sistema a,sistemas b where a.id_sistema = b.id_sistema and a.id_opciones_sistema in '."(".$filtro.") order by b.id_sistema,a.id_opciones_sistema ";
  
		$stmt = $this->dbh2->prepare($Sql);
		$stmt->execute();
		
		
		
		foreach ($stmt as $row) {
		
		        $respuesta->rows[$i]['id']=$row["id_opciones_sistema"];
				$respuesta->rows[$i]['des_sistema']=$row["des_sistema"];
				$respuesta->rows[$i]['des_opciones_sistema']=$row["des_opciones_sistema"];
				$respuesta->rows[$i]['id_sistema']=$row["id_sistema"];
                
                $i++;
		
   
   }// cierra sube data grid

     $this->dbh2 = null;
	
	 return json_encode($respuesta);
	
	
	 
	  
}// cierra metodo suba data grid

相关问题