<?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: Dynamic Column Names/Headers</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/dynamic-column-namesheaders</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/dynamic-column-namesheaders/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>heck0045 on Dynamic Column Names/Headers</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/dynamic-column-namesheaders#p20429</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/dynamic-column-namesheaders#p20429</guid>
        	        	<description><![CDATA[<blockquote>
<p>Yes, you can dynamically add columns, but the trick is to provide placeholders for them in the colmodel.</p>
</blockquote>
<blockquote>
</blockquote>
<blockquote>
<p>1. Provide a number of empty column names in the colModel definition -- I used 30, just an arbitrary number, expecting my search results to never require more than this....ensure that they are easily labeled: {name: &#39;p1&#39;, index: &#39;p1&#39;, hidden: true }...{name: &#39;p30&#39;, index:&#39;p30&#39;, hidden: true }</p>
</blockquote>
<blockquote>
<p>2. define the &#39;datatype: function(postData)&#39; function on your jqgrid to handle the custom loading of the ajax call, which will require you to add the JSON data to the grid yourself using the addJSONData(jsonObject) method with the jsonObject being correctly formatted per your colModel.</p>
</blockquote>
<blockquote>
<p>3. Inside your datatype function, you can then loop through your returned ajax results and use the below mechanism to dynamically rename and put titles on your hidden &#39;placeholder&#39; columns (all the p1...p30) that you have defined in the colmodel:&#160;</p>
</blockquote>
<blockquote>
<p>$("#jqGridId").jqGrid("setLabel", 6, "Dynamic Column Name");</p>
</blockquote>
<blockquote>
<p>$("#jqGrid").jqGrid(&#39;showCol", 6)</p>
</blockquote>
<blockquote>
<p>In the above, 6 is a reference to the colModel array index (so this would be the seventh column defined in the colModel). This way, because the columns change based on your searching, you can dynamically label and show as many columns (up to 30 in this case) as you need.&#160;</p>
</blockquote>
<blockquote>
<p>Hope this helps.</p>
</blockquote>
<blockquote>
</blockquote>
<blockquote>
</blockquote>
<blockquote>
<p>nmganesh said:</p>
</blockquote>
<blockquote>
<p>Hi,</p>
<p>Can anyone tell me if there is a way to dynamically change the column names/headers of the jqGrid?</p>
<p>For me the column names has to come from the Server data. Depending on the search criteria, data(no. of&#160; columns) changes.</p>
<p>Number of columns and rows of data will change depending on the search Criteria. Will it be possible to achieve this?</p>
</p>
<p>The Key here is, I need to get this column names information from the Server response.</p>
</p>
<p>Any help on this will be great....</p>
</blockquote>
<hr />
]]></description>
        	        	<pubDate>Fri, 22 Oct 2010 22:54:53 +0300</pubDate>
        </item>
        <item>
        	<title>nmganesh on Dynamic Column Names/Headers</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/dynamic-column-namesheaders#p20406</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/dynamic-column-namesheaders#p20406</guid>
        	        	<description><![CDATA[<p>Hi,</p>
<p>Can anyone tell me if there is a way to dynamically change the column names/headers of the jqGrid?</p>
<p>For me the column names has to come from the Server data. Depending on the search criteria, data(no. of&#160; columns) changes.</p>
<p>Number of columns and rows of data will change depending on the search Criteria. Will it be possible to achieve this?</p>
</p>
<p>The Key here is, I need to get this column names information from the Server response.</p>
</p>
<p>Any help on this will be great....</p>
]]></description>
        	        	<pubDate>Thu, 21 Oct 2010 17:10:40 +0300</pubDate>
        </item>
</channel>
</rss>