<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
	<title>jQuery Grid Plugin - jqGrid - Topic: Empty grid is displayed </title>
	<link>http://www.trirand.com/blog/?page_id=393/help/empty-grid-is-displayed</link>
	<description><![CDATA[Grid plugin]]></description>
	<generator>Simple:Press Version 5.7.5.3</generator>
	<atom:link href="http://www.trirand.com/blog/?page_id=393/help/empty-grid-is-displayed/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>KarthikOnIT on Empty grid is displayed </title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/empty-grid-is-displayed#p21835</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/empty-grid-is-displayed#p21835</guid>
        	        	<description><![CDATA[<p>Hi friends,</p>
<p>&#160;&#160; &#160; &#160;I am trying to integrate a grid to my PHP project, JQgrid looked so easy!!</p>
<p>When i Integrated I was only able to see the grid, not the data in the grid!</p>
<p>I have just change the db settings of the sample code to work with my DB.</p>
</p>
<p>Both files resides in root directory. Some clues to troubleshoot??</p>
</p>
<p>Here is the code&#160;</p>
</p>
<p>Myfirstgrid.php</p>
<p>******************************************</p>
<p>&#60;?php</p>
<p>require_once &#39;jq-config.php&#39;;</p>
<p>// include the jqGrid Class</p>
<p>require_once "php/jqGrid.php";</p>
<p>// include the PDO driver class</p>
<p>require_once "php/jqGridPdo.php";</p>
<p>// Connection to the server</p>
<p>$conn = new PDO(DB_DSN,DB_USER,DB_PASSWORD);</p>
<p>// Tell the db that we use utf-8</p>
<p>$conn-&#62;query("SET NAMES utf8");</p>
</p>
<p>// Create the jqGrid instance</p>
<p>$grid = new jqGridRender($conn);</p>
<p>// Write the SQL Query</p>
<p>//$grid-&#62;SelectCommand = &#39;SELECT id,Questiontext, c1, c2, c3, c4 FROM question&#39;;</p>
<p>//$grid-&#62;SelectCommand = &#39;SELECT * FROM prizequestion&#39;;</p>
<p>$grid-&#62;SelectCommand = &#39;SELECT * FROM question&#39;;</p>
<p>// set the ouput format to json</p>
<p>$grid-&#62;datatype = &#39;json&#39;;</p>
<p>// Let the grid create the model</p>
<p>$grid-&#62;setColModel();</p>
<p>// Set the url from where we obtain the data</p>
<p>$grid-&#62;setUrl(&#39;myfirstgrid.php&#39;);</p>
<p>// Set grid caption using the option caption</p>
<p>$grid-&#62;setGridOptions(array(</p>
<p>&#160;&#160;&#160; "caption"=&#62;"This is custom Caption",</p>
<p>&#160;&#160;&#160; "rowNum"=&#62;10,</p>
<p>&#160;&#160;&#160; "sortname"=&#62;"id",</p>
<p>&#160;&#160;&#160; "hoverrows"=&#62;true,</p>
<p>&#160;&#160;&#160; "rowList"=&#62;array(10,20,50),</p>
<p>&#160;&#160;&#160; ));</p>
<p>// Change some property of the field(s)</p>
<p>$grid-&#62;setColProperty("id", array("label"=&#62;"ID", "width"=&#62;60));</p>
<p>/*$grid-&#62;setColProperty("OrderDate", array(</p>
<p>&#160;&#160;&#160; "formatter"=&#62;"date",</p>
<p>&#160;&#160;&#160; "formatoptions"=&#62;array("srcformat"=&#62;"Y-m-d H:i:s","newformat"=&#62;"m/d/Y")</p>
<p>&#160;&#160;&#160; )</p>
<p>);*/</p>
<p>// Enjoy</p>
<p>$grid-&#62;renderGrid(&#39;#grid&#39;,&#39;#pager&#39;,true, null, null, true,true); //tried false in last two para&#39;s didn&#39;t work</p>
<p>/*response.setContentType("text/xml");</p>
<p>response.setCharacterEncoding("UTF-8?);*/</p>
<p>$conn = null;</p>
<p>?&#62;</p>
</p>
<p>**************************** END ***************</p>
<p>*************MYJQGRIDPHP.php***************************</p>
<p>&#60;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&#62;</p>
<p>&#60;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&#62;</p>
<p>&#60;head&#62;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&#62;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;title&#62;My First PHP jqGrid &#60;/title&#62;</p>
</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;link rel="stylesheet" media="screen" href="themes/redmond/jquery-ui-1.8.2.custom.css" /&#62;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;link rel="stylesheet" media="screen" href="themes/ui.jqgrid.css" /&#62;</p>
</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;script src="js/jquery.js" type="text/javascript"&#62;&#60;/script&#62;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;script src="js/i18n/grid.locale-en.js"&#62;&#60;/script&#62;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;script src="js/jquery.jqGrid.min.js" type="text/javascript"&#62;&#60;/script&#62;</p>
<p>&#60;/head&#62;</p>
<p>&#60;body&#62;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ......</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;table id=&#39;grid&#39;&#62;&#60;/table&#62;</p>
<p>&#160;&#160;&#160; &#60;div id=&#39;pager&#39;&#62;&#60;/div&#62;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;?php include "myfirstgrid.php" ?&#62;</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; .......</p>
<p>&#60;/body&#62;</p>
<p>&#60;/html&#62;</p>
</p>
<p>**************************************END*********************************</p>
]]></description>
        	        	<pubDate>Thu, 27 Jan 2011 03:01:48 +0200</pubDate>
        </item>
</channel>
</rss>