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_TopicIcon
no show data jqgrid codeigniter
09/11/2011
18:32
Avatar
bicu
New Member
Members
Forum Posts: 2
Member Since:
09/11/2011
sp_UserOfflineSmall Offline

error :

A PHP Error was encountered

Severity: Notice

Message: Undefined index: page

Filename: controllers/jqgrid.php

Line Number: 19

A PHP Error was encountered

Severity: Notice

Message: Undefined index: rows

Filename: controllers/jqgrid.php

Line Number: 22

no show data in jqgrid , code :

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
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(){
$page = $_GET['page'];
 
// get how many rows we want to have into the grid - rowNum parameter in the grid
$limit = $_GET['rows'];
 
// get index row - i.e. user click to sort. At first time sortname parameter -
// after that the index from colModel
$sidx = $_GET['sidx'];
 
// sorting order - at first time sortorder
$sord = $_GET['sord'];
 
// if we not pass at first time index use the first column for the index or what you want
if(!$sidx) $sidx =1;
// connect to the MySQL database server
$db = mysql_connect('localhost', 'root', 'root') or die("Connection Error: " . mysql_error());
// select the database
mysql_select_db('sampledb') or die("Error connecting to db.");
 
// calculate the number of rows for the query. We need this for paging the result
$result = mysql_query("SELECT COUNT(*) AS count FROM invheader");
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
 
 echo $count;
// calculate the total pages for the query
if( $count > 0 && $limit > 0) {
              $total_pages = ceil($count/$limit);
} else {
              $total_pages = 0;
}
 
// if for some reasons the requested page is greater than the total
// set the requested page to total page
if ($page > $total_pages) $page=$total_pages;
 
// calculate the starting position of the rows
$start = $limit*$page - $limit;
 
// if for some reasons start position is negative set it to 0
// typical case is that the user type 0 for the requested page
if($start <0) $start = 0;
 
// the actual query for the grid data
$SQL = "SELECT invid, invdate, amount, tax,total, note FROM invheader ORDER BY $sidx $sord LIMIT $start , $limit";
$result = mysql_query( $SQL ) or die("Couldn't execute query.".mysql_error());
 
// we should set the appropriate header information. Do not forget this.
header("Content-type: text/xml;charset=utf-8");
 
$s = "<?xml version='1.0' encoding='utf-8'?>";
$s .=  "<rows>";
$s .= "<page>".$page."</page>";
$s .= "<total>".$total_pages."</total>";
$s .= "<records>".$count."</records>";
 
// be sure to put text data in CDATA
while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
    $s .= "<row id='". $row['invid']."'>";            
    $s .= "<cell>". $row['invid']."</cell>";
    $s .= "<cell>". $row['invdate']."</cell>";
    $s .= "<cell>". $row['amount']."</cell>";
    $s .= "<cell>". $row['tax']."</cell>";
    $s .= "<cell>". $row['total']."</cell>";
    $s .= "<cell><![CDATA[". $row['note']."]]></cell>";
    $s .= "</row>";
}
$s .= "</rows>";
 
echo $s;
}
}

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My First Grid</title>
 
<link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url()?>asset/jqgrid/css/ui-lightness/jquery-ui-1.7.3.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="<?php echo base_url()?>asset/jqgrid/css/ui.jqgrid.css" />
 
<script src="<?php echo base_url(); ?>asset/jqgrid/js/jquery-1.5.2.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.min.js" type="text/javascript"></script>
 
<script type="text/javascript">
$(function(){
  $("#list").jqGrid({
    url:'<?php echo base_url().'index.php/jqgrid/example'?>',
    datatype: 'xml',
    mtype: 'get',
    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'}
    ],
    pager: '#gridpager',
    width: 600,
    height: 300,
    rowNum:10,
    rowList:[10,20,30],
    sortname: 'invid',
    sortorder: 'desc',
    viewrecords: true,
    gridview: 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>
 
</head>
<body>
<table id="list"><tr><td/></tr></table>
<div id="gridpager"></div>
</body>
</html>

thanks ::D

show $s xml formating:

<?xml version='1.0' encoding='utf-8'?>
<rows>
    <page>1</page>
    <total>1</total>
    <records>2</records>
    <row id='36'>
        <cell>36</cell>
        <cell>2010-12-12</cell>
        <cell>13.00</cell>
        <cell>13.00</cell>
        <cell>13.00</cell>
        <cell><![CDATA[13]]></cell>
    </row>
        <row id='34'>
            <cell>34</cell>
            <cell>2007-12-07</cell>
            <cell>45.00</cell>
            <cell>45.00</cell>
            <cell>45.00</cell>
            <cell><![CDATA[45]]></cell>
        </row>
</rows>

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
40 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