Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
jqgrid undefined codeigniter
09/11/2011
15:37
Avatar
bicu
New Member
Members
Forum Posts: 2
Member Since:
09/11/2011
sp_UserOfflineSmall Offline

I have a problem using codeigniter and jqGrid. The grid has the right design but does not load the data into the grid. the message displayed is undefined I leave the code below if you could help me. Thank you.

<head>

    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/themes/dark-hive/jquery-ui.css" type="text/css" rel="stylesheet"/>

    <link href="http://static.jquery.com/ui/css/demo-docs-theme/ui.theme.css" type="text/css" rel="stylesheet"/>

    <link type="text/css" href="<?php echo base_url()?>asset/jqgrid/css/ui.jqgrid.css" rel="stylesheet" />

    <link type="text/css" href="<?php echo base_url()?>asset/jqgrid/css/jquery.searchFilter.css" rel="stylesheet" />

    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js" type="text/javascript"></script>

    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.6/jquery-ui.min.js" type="text/javascript"></script>

    <script src="<?php echo base_url(); ?>'asset/jqgrid/js/i18n/grid.locale-en.js" type="text/javascript"></script>

    <script src="<?php echo base_url(); ?>asset/jqgrid/js/jquery.jqGrid.js" type="text/javascript"></script>

    <script src="<?php echo base_url(); ?>asset/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>



    <title>Jqgrid</title>

</head>



<body>

    <script type="text/javascript">

        jQuery().ready(function (){

            jQuery("#list").jqGrid({

                url:'<?php echo base_url().'index.php/jqgrid/example'?>',

                mtype : "post",

                datatype: "json",

                colNames:['Inv No','Date', 'Amount','Tax','Total','Notes'],

                 colModel :[
  {name:'invid', index:'invid', width:20},
  {name:'invdate', index:'invdate', width:90,  align:'center',editable:true, formatter:'date',editrules: { required: true, date:true}, formatoptions:{srcformat:'Y-m-d', newformat:'m/d/Y'}},
  {name:'amount', index:'amount', width:80, align:'center',editable:true,edittype:'text'},
  {name:'tax', index:'tax', width:80, align:'center',editable:true,edittype:'text'},
  {name:'total', index:'total', width:80, align:'center',editable:true, edittype:'text'},
  {name:'note', index:'note', width:150, align:'center', sortable:false,editable:true,edittype:'text'}
],

                rowNum:10,

                width: 800,

                height: 200,

                rowList:[10,20,30,40,50,60,70],

                pager: '#gridpager',

                sortname: 'invid',

                viewrecords: true,

                caption:"CLientes"

            }).navGrid('#gridpager',  

 {view:true,edit:true,add:true,del:true,search:true},
 {closeAfterEdit:true,modal:true}, // use default settings for edit
 {}, // use default settings for add
 {},  // delete instead that del:false we need this
 {}, // enable the advanced searching
 {closeOnEscape:true} /* allow the view dialog to be closed when user press ESC key*/
  );
  });
  </script>



    <table id="list"></table>

    <div id="gridpager"></div>

</body>

----------------------------------------------------------------------------------------------

class cliente extends CI_Model{

function __construct()

{

    parent::__construct();

}

function cargar()

{

    $q = $this->db->query("select * from invheader");

    return $q;

}

}

------------------------------------------------------------------------------------------------------------------------------------------------------

class jqgrid extends CI_Controller {

function __construct()

{

    parent::__construct();

    $this->load->helper(array('url'));

    $this->load->model('cliente');

    $this->load->database();

}



function index()

{

        $this->load->view('jqgrid/home');

}



function example(){

    $hal = isset($_POST['page'])?$_POST['page']:1;

    $batas = isset($_POST['rows'])?$_POST['rows']:10;

    $sidx = isset($_POST['sidx'])?$_POST['sidx']:'invid';



    if(!$sidx) $sidx =1;

    $q = $this->cliente->cargar();



    $hitung = count($q);



    if( $hitung > 0 ) {

        $total_hal = ceil($hitung/$batas);

    } else {

        $total_hal = 0;

    }



    if ($hal > $total_hal) $hal=$total_hal;



    $start = $batas*$hal - $batas;

    $start = ($start<0)?0:$start;



    $data->page = $hal;

    $data->total = $total_hal;

    $data->records = $hitung;

    $i=0;

    foreach($q->result() as $row) {

        $data->rows[$i]['id']=$row->invid;

        $data->rows[$i]['cell']=array($i+1,$row->invdate,$row->amount,$row->tax,$row->total,$row->note);

        $i++;

    }

    echo json_encode($data);

}

}

thanks.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
18 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

OlegK: 1255

markw65: 179

kobruleht: 144

phicarre: 132

YamilBracho: 124

Renso: 118

Member Stats:

Guest Posters: 447

Members: 11373

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 8

Topics: 10592

Posts: 31289

Newest Members:

, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information