1

Hello I've been working on this for almost 2 hours now. I can't seem to find the error about the result not being shown on jqGrid. I tried echoing json_encode and it displayed. My jqGrid is working on my local site but not on the live one. I am passing a parameter so that it will not show other items that are not included.

Here's what I got:

//Controller

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();
    }
xxxo_tryme
  • 213
  • 1
  • 2
  • 12
  • What's the error message? Questions that only say "Not Working" don't show due diligence. Cross domain problem? – Ruan Mendes Feb 16 '12 at 02:35
  • No error message. Doesn't display the result. – xxxo_tryme Feb 16 '12 at 02:39
  • 3
    I recommend you always to include `loadError` callback in the jqGrid definition (see [the answer](http://stackoverflow.com/a/6969114/315935) for more information). Moreover it's good to append your answer with the full JSON response from the server. You can use [Fiddler](http://www.fiddler2.com/fiddler2/) or [Firebug](http://getfirebug.com/) to catch the HTTP traffic. Additionally it's important to examine "Content-Type" in the HTTP headers. It must be "application/json". All the information will shows whether the origin of the problem are on the server or on the client part. – Oleg Feb 16 '12 at 07:02
  • Are you using the full source js or compressed js version of jqGrid? I found that I had issues using the full source when going using jqGrid on my live version. Locally it ran fine. – Jpepper Feb 27 '12 at 17:15

1 Answers1

0

What is the error message...browse your page with Google chrome and press F12 or Inspect element in right hand side you can find error..please post the error also.Check your js and css file are referred path right or not...

example:-

< script src="../../../Script/jquery-ui-1.7.2.custom.min.js" type="text/javascript" >

or use Resolve URL

Lawren Alex
  • 110
  • 5