<?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: jqgrid with jquery ui tabs and json</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/jqgrid-with-jquery-ui-tabs-and-json</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/jqgrid-with-jquery-ui-tabs-and-json/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>tony on jqgrid with jquery ui tabs and json</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/jqgrid-with-jquery-ui-tabs-and-json#p12633</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/jqgrid-with-jquery-ui-tabs-and-json#p12633</guid>
        	        	<description><![CDATA[<p>Hello,</p>
<p>From what I see into the code you call every time the creation of grid when a tab is selected.</p>
<p>Here you can solve the problem diffrent ways</p>
<p>1. Use GridUnload method before constructing the grid - e.g</p>
<p>$(&#8221;#volunteer_grid&#8221;).GridUnload();</p>
<p>$(&#8221;#volunteer_grid&#8221;).jqGrid({...});</p>
<p>2. Check to see if the grid is already created and if so just open a tab (or maybe trigger the grid to refresh the data)</p>
<p>var maygrid = $(&#8221;#volunteer_grid&#8221;);</p>
<p>if(mygrid[0].grid) {</p>
<p>// refresh it mybe</p>
<p>} else {</p>
<p>// create grid</p>
<p>}</p>
</p>
<p>Best Regards</p>
<p>Tony</p>
]]></description>
        	        	<pubDate>Wed, 02 Dec 2009 10:00:52 +0200</pubDate>
        </item>
        <item>
        	<title>pvdm on jqgrid with jquery ui tabs and json</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/jqgrid-with-jquery-ui-tabs-and-json#p12599</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/jqgrid-with-jquery-ui-tabs-and-json#p12599</guid>
        	        	<description><![CDATA[<p>Hello jqgrid experts</p>
</p>
<p>I started writing an application using codeigniter as php framework for database access and MVC on the server side an jquery and jqgrid on the client side.&#160;</p>
<p>Last week, I successfully implemented a dynamic web page with a jqgrid by using ajax, json and POST.</p>
<p>To debug, I use firefox, firebug and firephp. I see clearly a post request going to the server and an appropriate answer with the table data in json format. Rendering of the grid is just fine.</p>
</p>
<p>But now I want to incorporate things in&#160;2 or more tabs using jquery ui tabs (like in the demo), some of them with a jqgrid, others with forms or just static content.</p>
<p>The first tab should contain the grid and some static content, the other tab a form.</p>
</p>
<p>But when switching between tabs, some strange (at least for me) happen.</p>
<p>When I switch to the tab which should contain the grid, I see a post request returning all the data for the jqgrid, immediately followed by a post request with the html page where the grid should be shown. The grid flashes up and is overwritten by the html page.</p>
<p>Something is wrong in the order of execution, but I am stuck and I am sure there is just a simple answer to my question.</p>
<p>Could someone help me out</p>
</p>
<p>some javascript:</p>
</p>
<p>$(document).ready(function() &#160;{</p>
</p>
<p><span> </span>$("#navmenu").tabs();</p>
<p><span> </span>$("#navmenu").tabs(&#39;add&#39;, &#39;index.php/volunteer/show_list&#39;, &#39;Lijstje1&#39;);</p>
<p><span> </span>$("#navmenu").tabs(&#39;add&#39;, &#39;index.php/volunteer/show_form&#39;, &#39;Lijstje2&#39;);</p>
<p>$("#navmenu").bind(&#39;tabsselect&#39;, function(event, ui) {</p>
<p><span style="white-space: pre;"> </span>gridding();</p>
<p><span style="white-space: pre;"> </span>alert(ui.panel);</p>
<p><span> </span>});</p>
<p><span> </span>$("#navmenu").tabs(&#39;option&#39;, &#39;ajaxOptions&#39;, { type: "POST" });</p>
<p>});</p>
</p>
<p>function gridding()&#160;</p>
<p>{</p>
<p><span> </span>// GRID SETUP</p>
<p><span> </span>$("#volunteer_grid").jqGrid({</p>
<p><span> </span>/* Basics */</p>
<p><span> </span>url:&#39;<a href="http://localhost/intro_manager/index.php/volunteer/ajax_list_volunteers_json&#038;#39" rel="nofollow" target="_blank"><a href="http://localhost/intro_manager" rel="nofollow">http://localhost/intro_manager</a>.....n&#038;#39</a>;,</p>
<p><span> </span>datatype: "json",</p>
<p><span> </span>mtype: &#39;POST&#39;,</p>
<p><span> </span>colNames:[&#39;ID&#39;,&#39;First Name&#39;, &#39;Last Name&#39;, &#39;Email&#39;],</p>
<p><span> </span>colModel:[ {name:&#39;id&#39;,index:&#39;id&#39;,hidden:true, width:55},</p>
<p><span> </span> &#160; {name:&#39;first_name&#39;,index:&#39;first_name&#39;, sortable: true, width:120},</p>
<p><span> </span> &#160; {name:&#39;last_name&#39;,index:&#39;last_name&#39;, width:200},</p>
<p>&#160;<span> </span> &#160; {name:&#39;email&#39;,index:&#39;email&#39;, width:200}</p>
<p><span> </span> ],</p>
<p><span> </span> rowNum:10,</p>
<p><span> </span> rowList:[10,20,30],</p>
<p><span> </span> /*imgpath: gridimgpath, */</p>
<p><span> </span>pager: $(&#39;#volunteer_pager&#39;),</p>
<p><span> </span>sortname: &#39;id&#39;,</p>
<p><span> </span>sortorder: &#39;asc&#39;,</p>
<p><span> </span>caption:"Vrijwilligers lijst",</p>
<p>/* Other */</p>
<p><span> </span>cellEdit: false,</p>
<p><span> </span>hidegrid: false,</p>
<p>loadui: &#39;disable&#39;,</p>
<p><span> </span>shrinkToFit: true,</p>
<p><span> </span>//<span> </span> viewrecords: true,</p>
<p><span> </span>height: 300,</p>
<p><span> </span>altRows: false,</p>
<p><span> </span>multiselect: false,</p>
<p><span> </span>scrollRows: true,</p>
<p><span> </span>loadtext: &#39;Vrijwilligers ophalen&#39;,</p>
<p>}).navGrid(&#39;#volunteer_pager&#39;,{edit:false,add:false,del:false});</p>
<p>}</p>
<p>the php (codeigniter)</p>
</p>
<p><span> </span>function show_list()</p>
<p><span> </span>{</p>
<p><span> </span>echo &#39;blablabla&#39;;</p>
<p><span> </span>echo &#160;$this-&#62;load-&#62;view(&#39;volunteer_list&#39;, &#39;&#39;,TRUE);</p>
<p><span> </span>}</p>
</p>
<p><span> </span>function show_form()</p>
<p><span> </span>{</p>
<p><span> </span>echo &#160;$this-&#62;load-&#62;view(&#39;volunteer_form&#39;, &#39;&#39;,TRUE);</p>
<p><span> </span>}</p>
</p>
<p>// the ajax_volunteers_json just returns the appropriate json data</p>
</p>
<p>function ajax_list_volunteers_json() {</p>
<p><span> </span></p>
<p><span> </span>$page = $this-&#62;input-&#62;post(&#39;page&#39;); &#160;// get the requested page&#160;</p>
<p><span> </span>$limit = $this-&#62;input-&#62;post(&#39;rows&#39;); // get how many rows we want to have into the grid&#160;</p>
<p><span> </span>$sidx = $this-&#62;input-&#62;post(&#39;sidx&#39;); &#160;// get index row - i.e. user click to sort&#160;</p>
<p><span> </span>$sord = $this-&#62;input-&#62;post(&#39;sord&#39;); &#160;// get the direction&#160;</p>
<p><span> </span></p>
<p><span> </span>if(!$sidx) $sidx =1; // connect to the database&#160;</p>
<p><span> </span></p>
<p><span> </span>$count = $this-&#62;volunteer_model-&#62;count_volunteers();</p>
</p>
<p><span> </span>if( $count &#62;0 ) {&#160;</p>
<p><span> </span>$total_pages = ceil($count/$limit);&#160;</p>
<p><span> </span>} else {&#160;</p>
<p><span> </span>$total_pages = 0;&#160;</p>
<p><span> </span>}&#160;</p>
<p><span> </span>if ($page &#62; $total_pages) $page=$total_pages;&#160;</p>
<p><span> </span></p>
<p><span> </span>$start = $limit*$page - $limit; // do not put $limit*($page - 1)&#160;</p>
</p>
<p><span> </span>$data = $this-&#62;volunteer_model-&#62;list_volunteers2($limit, $start);</p>
<p><span> </span></p>
<p><span> </span>$response-&#62;page = $page;&#160;</p>
<p><span> </span>$response-&#62;total = $total_pages;&#160;</p>
<p><span> </span>$response-&#62;records = $count;&#160;</p>
<p><span> </span></p>
<p><span> </span>$i=0;</p>
<p><span> </span>foreach ($data as $row)</p>
<p><span> </span>{</p>
<p><span> </span>$response-&#62;rows[$i][&#39;id&#39;]=$row-&#62;id;&#160;</p>
<p><span> </span>$response-&#62;rows[$i][&#39;cell&#39;]=array($row-&#62;id,$row-&#62;first_name,$row-&#62;last_name,$row-&#62;email); <span> </span></p>
<p><span> </span>$i++;<span> </span></p>
<p><span> </span>}</p>
</p>
<p><span> </span>echo json_encode($response);</p>
<p><span> </span>}</p>
</p>
<p>the view</p>
</p>
<p>&#60;div&#62;&#60;/div&#62;</p>
<p>&#60;table id="volunteer_grid" class="scroll" cellpadding="0" cellspacing="0"&#62;</p>
<p>&#60;/table&#62; &#60;div id="volunteer_pager" class="scroll" style="text-align:center;"&#62;&#60;/div&#62;&#160;</p>
</p>
<p>&#60;p&#62;&#60;input id="mybutton" type="button" value="Select Columns to view"&#62;&#60;/p&#62;</p>
<p>&#60;p&#62;&#60;div id="mysearch"&#62;&#60;/div&#62;&#60;/p&#62;</p></p>
]]></description>
        	        	<pubDate>Mon, 30 Nov 2009 19:06:40 +0200</pubDate>
        </item>
</channel>
</rss>