Welcome Guest, Not a member yet? Register   Sign In
jqgrid + codeigniter I can make jqgrid work in codeigniter
#1

[eluser]ivanrvm[/eluser]
I tried to make jqgrid work with codeigniter, but I could not do it, I only want to show the data from the table in json format... but nothing happens.. but i dont know what i am doing wrong, i cant see the table with the content i am calling.

my controller

Code:
class Grid extends Controller
  {
  
      public function f()
      {
          
             $this->load->model('dbgrid');
             $var['grid'] =  $this->dbgrid->getcontentfromtable();
             $i = 0;
             foreach($var['grid'] as $row) {
            $responce->rows[$i]['id']=$row->id;
            $responce->rows[$i]['cell']=array($row->id,$row->id_catalogo);
              $i++;
             }
       echo json_encode($responce);
          
      

          
      }
      
        
      function load_view_grid()
      {
          
          $this->load->view('vgrid');
          
          
      }
      
      
  }

my model
Code:
class Dbgrid extends Model{

   function getcontentfromtable()
   {
      
      
         $sql = 'SELECT * FROM anuncios';
         $query = $this->db->query($sql);
         $result = $query->result();
        
        
         return $result;
      
      
      
      
   }

}

my view
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
&lt;html &gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
&lt;title&gt;my grid&lt;/title&gt;
  
&lt;link rel="stylesheet" type="text/css" media="screen" href="http://localhost/themes/redmond/jquery-ui-1.8.1.custom.css" /&gt;
&lt;link rel="stylesheet" type="text/css" media="screen" href="http://localhost/themes/ui.jqgrid.css" /&gt;


[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed][removed]
[removed]
    $.jgrid.no_legacy_api = true;
    $.jgrid.useJSON = true;
[removed]
[removed][removed]

[removed]
  
$(document).ready(function() {
    
     jQuery("#list27").jqGrid({
            url:'http://localhost/sitio/index.php/grid/f/',
            datatype: "json",
            mtype: "post",
            height: 255,
            width: 600,
               colNames:['ID','ID_CATALOGO'],
               colModel:[
                   {name:'id',index:'id', width:65},
                   {name:'id_catalogo',index:'id_catalogo'}
          
          
               ],
               rowNum:50,
            rowTotal: 2000,
            rowList : [20,30,50],
            loadonce:true,
            rownumbers: true,
            rownumWidth: 40,
            gridview: true,
               pager: '#pager27',
            viewrecords: true,
            sortorder: "asc",
            caption: "Loading data from server at once"    
        });

});

[removed]
&lt;body&gt;

                    <table id="list27" cellpadding="0" cellspacing="0"></table>
                    <div id="pager27" class="scroll" style="text-align: center;"></div>

&lt;/body&gt;
&lt;/html&gt;

this is the output
Code:
{"rows":[

  {"id":"1","cell":["1","225101503"]},
  {"id":"3","cell":["3","225101503"]},
  {"id":"4","cell":["4","225101503"]},
  {"id":"6","cell":["6","225101503"]},
  {"id":"5","cell":["5","225101503"]},
  {"id":"7","cell":["7","452101500"]},
  {"id":"8","cell":["8","330000000"]},
  {"id":"9","cell":["9","110101511"]},
  {"id":"10","cell":["10","110101502"]},
  {"id":"11","cell":["11","225101503"]}

]
}
But I can not see that output in the table that is in the view.
hope someone can help me
#2

[eluser]ivanrvm[/eluser]
I've found the solution...
#3

[eluser]kikz4life[/eluser]
nice, i had done that using jqgrid as datagrid in my application also using json.
#4

[eluser]coder5[/eluser]
hi,, ivanrvm ,,,
So is your jqgrid workin'?
#5

[eluser]ivanrvm[/eluser]
[quote author="coder5" date="1275150502"]hi,, ivanrvm ,,,
So is your jqgrid workin'?[/quote]

Yeap it`s working.
#6

[eluser]coder5[/eluser]
[quote author="ivanrvm" date="1275205238"][quote author="coder5" date="1275150502"]hi,, ivanrvm ,,,
So is your jqgrid workin'?[/quote]

Yeap it`s working.[/quote]

Is it just like the example you made above ?
#7

[eluser]ivanrvm[/eluser]
[quote author="coder5" date="1275209579"][quote author="ivanrvm" date="1275205238"][quote author="coder5" date="1275150502"]hi,, ivanrvm ,,,
So is your jqgrid workin'?[/quote]

Yeap it`s working.[/quote]

Is it just like the example you made above ?[/quote]

Yeap... It`s the same thats working on my server. Why?




Theme © iAndrew 2016 - Forum software by © MyBB