2012-02-16 71 views
1

你好我一直在这个工作了近2个小时了。我似乎无法找到关于结果不显示在jqGrid上的错误。我试着回显json_encode并显示出来。我的jqGrid正在我的本地网站上工作,但没有在现场。我传递一个参数,以便它不会显示其他未包含的项目。jqGrid无法在Live网站上工作

这里就是我的了:

//控制器

function all ($eid) 
    { 
     $page = isset($_POST['page'])?$_POST['page']:1; 
     $limit = isset($_POST['rows'])?$_POST['rows']:10; 
     $sidx = isset($_POST['sidx'])?$_POST['sidx']:'rank'; 
     $sord = isset($_POST['sord'])?$_POST['sord']:'';   
     $start = $limit*$page - $limit; 
     $start = ($start<0)?0:$start; 

     $where = ""; 
    $searchField = isset($_POST['searchField']) ? $_POST['searchField'] : false; 
     $searchOper = isset($_POST['searchOper']) ? $_POST['searchOper']: false; 
     $searchString = isset($_POST['searchString']) ? $_POST['searchString'] : false; 

     if (isset($_POST['_search']) == 'true') { 
      $ops = array(
       'eq'=>'=', 
       'ne'=>'<>', 
       'lt'=>'<', 
       'le'=>'<=', 
       'gt'=>'>', 
       'ge'=>'>=', 
       'bw'=>'LIKE', 
       'bn'=>'NOT LIKE', 
       'in'=>'LIKE', 
       'ni'=>'NOT LIKE', 
       'ew'=>'LIKE', 
       'en'=>'NOT LIKE', 
       'cn'=>'LIKE', 
       'nc'=>'NOT LIKE' 
      ); 
     foreach ($ops as $key=>$value){ 
      if ($searchOper==$key) { 
       $ops = $value; 
      } 
     } 
     if($searchOper == 'eq') $searchString = $searchString; 
     if($searchOper == 'bw' || $searchOper == 'bn') $searchString .= '%'; 
     if($searchOper == 'ew' || $searchOper == 'en') $searchString = '%'.$searchString; 
     if($searchOper == 'cn' || $searchOper == 'nc' || $searchOper == 'in' || $searchOper == 'ni') $searchString = '%'.$searchString.'%'; 

     $where = "$searchField $ops '$searchString'"; 

    } 

    if(!$sidx) 
     $sidx =1; 
    //$this->db->where('event_id', $eid); 
    $count = $this->db->count_all_results('table1'); 
    if($count > 0) { 
     $total_pages = ceil($count/$limit);  
    } else { 
     $total_pages = 0; 
    } 

    if ($page > $total_pages) 
     $page=$total_pages; 
     $query = $this->Manager_model->getcontentfromtable($start,$limit,$sidx,$sord,$where, $eid); 
     $responce->page = $page; 
     $responce->total = $total_pages; 
     $responce->records = $count; 
     $i=0; 
     foreach($query as $row) { 
      $responce->rows[$i]['rank']=$row->rank; 
      $pace = time_to_sec($row->runner_time)/$row->runner_cat; 
      $pacex = sec_to_time($pace); 
      $responce->rows[$i]['cell']=array($row->rank,$row->runner_name,$row->runner_cat,$row->runner_bib,$row->runner_time,$pacex); 
      $i++; 
     } 

    echo json_encode($responce); 
    } 


//View 

<table id="list" cellpadding="0" cellspacing="0"></table> 
<div id="pager" class="scroll" style="text-align:center;"></div> 
</div> 
<script type="text/javascript"> 
     $(document).ready(function(){ 
      jQuery("#list").jqGrid({ 
       url: '<?php echo MAINSITE_INDEX."manager/all/$eid" ?>',  //another controller function for generating data 
       mtype : "post",    //Ajax request type. It also could be GET 
       datatype: "json",   //supported formats XML, JSON or Arrray 
       colNames:['Rank','Runner Name','Category','BIB','Time','Pace'],  //Grid column headings 
       colModel :[{ 
        name:'rank' 
        ,index:'rank' 
        ,width:55 
       },{ 
        name:'runner_name' 
        ,index:'runner_name' 
        ,width:90 
        ,editable:true 
       },{ 
        name:'runner_cat' 
        ,index:'runner_cat' 
        ,width:80 
        ,align:'right' 
        ,editable:true 

       },{ 
        name:'runner_bib' 
        ,index:'runner_bib' 
        ,width:80 
        ,align:'rbib' 
        ,editable:true 
       },{ 
        name:'runner_time' 
        ,index:'runner_time' 
        ,width:80 
        ,align:'right' 
        ,editable:true 
       },{ 
        name:'pacex' 
        ,index:'pacex' 
        ,width:150 
        ,sortable:false 
        ,editable:false 
       }], 


       rowNum:10, 
       width: 1050, 
       height: 300, 
       rowList:[10,20,30], 
       pager: '#pager', 
       sortname: 'rank', 
       viewrecords: true, 
       rownumbers: true, 
       gridview: true, 
       caption:"List", 
       viewPagerButtons: true 
      }).navGrid('#pager',{edit:true,add:false,del:false}); 


     }); 
    </script> 


Model: 

    function getcontentfromtable($start, $limit, $sidx, $sord, $where, $eid){ 
     $this->db->select('*'); 
     $this->db->limit($limit); 
     $this->db->where('event_id', $eid); 
     if($where != NULL) 
     $this->db->where($where,NULL,FALSE); 

     $this->db->order_by($sidx,$sord); 
     $query = $this->db->get('table1',$limit,$start); 

     return $query->result(); 
    } 
+0

有什么错误信息?只有说“不工作”的问题没有显示尽职调查。跨域问题? – 2012-02-16 02:35:58

+0

没有错误信息。不显示结果。 – 2012-02-16 02:39:06

+3

我建议你总是在jqGrid定义中包含'loadError'回调函数(更多信息见[答案](http://stackoverflow.com/a/6969114/315935))。此外,还可以将答案附加在服务器的完整JSON响应中。您可以使用[Fiddler](http://www.fiddler2.com/fiddler2/)或[Firebug](http://getfirebug.com/)来捕获HTTP流量。另外,检查HTTP标题中的“Content-Type”很重要。它必须是“application/json”。所有信息将显示问题的根源是在服务器还是在客户端部分。 – Oleg 2012-02-16 07:02:08

回答

0

什么是错误讯息...浏览网页,谷歌Chrome和按F12或检查的右手边元素,你可以找到error..please发布错误also.Check你的JS和CSS文件被称为路径正确与否......

例如: -

< SC RIPT SRC = “../../../脚本/ jQuery的UI-1.7.2.custom.min.js” 类型= “文/ JavaScript的”>

,或者使用解决URL

相关问题