<?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: Can't Add, Edit, Delete records in Database</title>
	<link>http://www.trirand.com/blog/?page_id=393/treegrid/cant-add-edit-delete-records-in-database</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/treegrid/cant-add-edit-delete-records-in-database/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>richsoe on Can't Add, Edit, Delete records in Database</title>
        	<link>http://www.trirand.com/blog/?page_id=393/treegrid/cant-add-edit-delete-records-in-database#p14922</link>
        	<category>TreeGrid</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/treegrid/cant-add-edit-delete-records-in-database#p14922</guid>
        	        	<description><![CDATA[<p>This topic was created in the wrong thread. This is discontinued, and the discussion can be found here <a href="http://www.trirand.com/blog/?page_id=393/help/cant-add-edit-delete-records-in-database-1/" rel="nofollow" target="_blank"><a href="http://www.trirand.com/blog/?p" rel="nofollow">http://www.trirand.com/blog/?p</a>.....atabase-1/</a>.</p>
]]></description>
        	        	<pubDate>Thu, 18 Feb 2010 03:53:56 +0200</pubDate>
        </item>
        <item>
        	<title>richsoe on Can't Add, Edit, Delete records in Database</title>
        	<link>http://www.trirand.com/blog/?page_id=393/treegrid/cant-add-edit-delete-records-in-database#p14874</link>
        	<category>TreeGrid</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/treegrid/cant-add-edit-delete-records-in-database#p14874</guid>
        	        	<description><![CDATA[<p>I downloaded the demo files and followed the "navigator" sample but couldn&#39;t get add/edit/delete functioning properly. It only updates the gridview but not the DB. After page refresh, the data remains the same as original.</p>
</p>
<p>I&#39;m using the javascript version and this is somehow different from the commercial version. Should we write our own insert/update/delete manually? Or, this is being handled by the library itself? Or, is this possibly another issue I am facing?</p>
</p>
<p>Kinda confused.</p>
]]></description>
        	        	<pubDate>Wed, 17 Feb 2010 12:13:23 +0200</pubDate>
        </item>
        <item>
        	<title>tony on Can't Add, Edit, Delete records in Database</title>
        	<link>http://www.trirand.com/blog/?page_id=393/treegrid/cant-add-edit-delete-records-in-database#p14867</link>
        	<category>TreeGrid</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/treegrid/cant-add-edit-delete-records-in-database#p14867</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>Dowload the demo files and see.</p>
<p>Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Wed, 17 Feb 2010 11:58:36 +0200</pubDate>
        </item>
        <item>
        	<title>richsoe on Can't Add, Edit, Delete records in Database</title>
        	<link>http://www.trirand.com/blog/?page_id=393/treegrid/cant-add-edit-delete-records-in-database#p14852</link>
        	<category>TreeGrid</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/treegrid/cant-add-edit-delete-records-in-database#p14852</guid>
        	        	<description><![CDATA[<p>How this jqGrid is actually performing search, add, edit, delete to DB? I can&#39;t get it working, I can only select.</p>
<p>If I add, edit, or delete, it just update the UI / gridview.</p>
<p><strong>Here is my table:</strong></p>
<p>CREATE TABLE `vip_queue` (&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; `id` INT(11) NOT NULL AUTO_INCREMENT,&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; `username` VARCHAR(64) DEFAULT NULL,&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; `group_id` SMALLINT(3) DEFAULT NULL,&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; PRIMARY KEY&#160; (`id`),&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; UNIQUE KEY `username` (`username`)&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#160;<br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ) ENGINE=INNODB AUTO_INCREMENT=65 DEFAULT CHARSET=utf8</p>
<p><strong>Here is my Javascript:</strong></p>
<p>&#60;script type="text/javascript"&#62;<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;jQuery(document).ready(function(){<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;jQuery("#list").jqGrid({<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;url:&#39;admin.vip.queue.process.php&#39;,<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;datatype: "json",<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;mtype: "POST",<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;colNames:[&#39;vip_id&#39;,&#39;username&#39;, &#39;group_id&#39;],<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;colModel:[<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{name:&#39;vip_id&#39;, index:&#39;vip_id&#39;, width:100, editable:false, editoptions:{readonly:true}, editrules:{required:false}},<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{name:&#39;username&#39;, index:&#39;username&#39;, width:300, editable:true, edittype:&#39;text&#39;},<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{name:&#39;group_id&#39;, index:&#39;group_id&#39;, width:200, editable:true, edittype:&#39;text&#39;}<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;],<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;pager: &#39;#pagernav&#39;,<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;rowNum:50,<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;rowList:[10,50,100,200,500,1000],<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;sortname: &#39;vip_id&#39;,<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;sortorder: "asc",<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;viewrecords: true,<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;caption: "Manage VIP Queue",<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;editurl: "admin.vip.queue.process.php",<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;height: 400<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;});<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;jQuery("#list").jqGrid(&#39;navGrid&#39;,&#39;#pagernav&#39;,<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{}, //options<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{mtype:"POST",closeAfterEdit:true,reloadAfterSubmit:true}, // edit options<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{mtype:"POST",closeAfterAdd:true,reloadAfterSubmit:true}, // add options<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{mtype:"POST",reloadAfterSubmit:true}, // del options<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;{} // search options<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;);<br />&#160;&#160; &#160;&#160;&#160; &#160;&#160;&#160; &#160;});<br />&#160;&#160; &#160;&#160;&#160; &#160;&#60;/script&#62;</p>
</p>
<p><strong>Here is my php script:</strong></p>
<p>require_once(&#39;class/db.php&#39;);<br />$db= new db();<br />$writeConn = $db-&#62;getWriteConnection();<br />$debug = false;</p>
<p>$page = $_POST[&#39;page&#39;]; // get the requested page<br />$limit = $_POST[&#39;rows&#39;]; // get how many rows we want to have into the grid<br />$sidx = $_POST[&#39;sidx&#39;]; // get index row &#8211; i.e. user click to sort<br />$sord = $_POST[&#39;sord&#39;]; // get the direction<br />if(!$sidx) $sidx =1;</p>
<p>$sql = "SELECT COUNT(id) as count FROM vip";<br />$result = $db-&#62;query($sql, $debug, $writeConn);<br />$row = mysql_fetch_array($result);<br />$count = $row[&#39;count&#39;];</p>
<p>if( $count &#62;0 ) {<br />&#160;&#160; &#160;$total_pages = ceil($count/$limit);<br />} else {<br />&#160;&#160; &#160;$total_pages = 0;<br />}<br />if ($page &#62; $total_pages) $page=$total_pages;<br />$start = $limit*$page &#8211; $limit; // do not put $limit*($page &#8211; 1)<br />if ($start&#60;0) $start = 0;</p>
<p>$sql = "SELECT id as &#39;vip_id&#39;, username, group_id FROM vip ORDER BY ".$sidx." ". $sord." LIMIT ".$start." , ".$limit;<br />$result = $db-&#62;query($sql, $debug, $writeConn);</p>
<p>$response-&#62;page = $page; <br />$response-&#62;total = $total_pages; <br />$response-&#62;records = $count; <br />$i = 0;<br />while($row = mysql_fetch_array($result)) <br />{<br />&#160;&#160; &#160;$response-&#62;rows[$i][&#39;id&#39;]=$row[&#39;vip_id&#39;]; <br />&#160;&#160; &#160;$response-&#62;rows[$i][&#39;cell&#39;]=array($row[&#39;vip_id&#39;],$row[&#39;username&#39;],$row[&#39;group_id&#39;]); <br />&#160;&#160; &#160;$i++; &#160;&#160; &#160;<br />}<br />echo json_encode($response); <br />$db-&#62;close($writeConn);</p>
</p>
<p>Please help. Thx</p></p>
]]></description>
        	        	<pubDate>Wed, 17 Feb 2010 10:50:24 +0200</pubDate>
        </item>
</channel>
</rss>