Forum
03:01
27/01/2011
Hi friends,
I am trying to integrate a grid to my PHP project, JQgrid looked so easy!!
When i Integrated I was only able to see the grid, not the data in the grid!
I have just change the db settings of the sample code to work with my DB.
Both files resides in root directory. Some clues to troubleshoot??
Here is the code
Myfirstgrid.php
******************************************
<?php
require_once 'jq-config.php';
// include the jqGrid Class
require_once "php/jqGrid.php";
// include the PDO driver class
require_once "php/jqGridPdo.php";
// Connection to the server
$conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);
// Tell the db that we use utf-8
$conn->query("SET NAMES utf8");
// Create the jqGrid instance
$grid = new jqGridRender($conn);
// Write the SQL Query
//$grid->SelectCommand = 'SELECT id,Questiontext, c1, c2, c3, c4 FROM question';
//$grid->SelectCommand = 'SELECT * FROM prizequestion';
$grid->SelectCommand = 'SELECT * FROM question';
// set the ouput format to json
$grid->datatype = 'json';
// Let the grid create the model
$grid->setColModel();
// Set the url from where we obtain the data
$grid->setUrl('myfirstgrid.php');
// Set grid caption using the option caption
$grid->setGridOptions(array(
"caption"=>"This is custom Caption",
"rowNum"=>10,
"sortname"=>"id",
"hoverrows"=>true,
"rowList"=>array(10,20,50),
));
// Change some property of the field(s)
$grid->setColProperty("id", array("label"=>"ID", "width"=>60));
/*$grid->setColProperty("OrderDate", array(
"formatter"=>"date",
"formatoptions"=>array("srcformat"=>"Y-m-d H:i:s","newformat"=>"m/d/Y")
)
);*/
// Enjoy
$grid->renderGrid('#grid','#pager',true, null, null, true,true); //tried false in last two para's didn't work
/*response.setContentType("text/xml");
response.setCharacterEncoding("UTF-8?);*/
$conn = null;
?>
**************************** END ***************
*************MYJQGRIDPHP.php***************************
<!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 PHP jqGrid </title>
<link rel="stylesheet" media="screen" href="themes/redmond/jquery-ui-1.8.2.custom.css" />
<link rel="stylesheet" media="screen" href="themes/ui.jqgrid.css" />
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/i18n/grid.locale-en.js"></script>
<script src="js/jquery.jqGrid.min.js" type="text/javascript"></script>
</head>
<body>
......
<table id='grid'></table>
<div id='pager'></div>
<?php include "myfirstgrid.php" ?>
.......
</body>
</html>
**************************************END*********************************
Most Users Ever Online: 715
Currently Online:
36 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.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66