<?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: MVC3 subGridRowExpanded action not firing</title>
	<link>http://www.trirand.com/blog/?page_id=393/help/mvc3-subgridrowexpanded-action-not-firing</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/mvc3-subgridrowexpanded-action-not-firing/rss" rel="self" type="application/rss+xml" />
        <item>
        	<title>AHumphries on MVC3 subGridRowExpanded action not firing</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/mvc3-subgridrowexpanded-action-not-firing#p27490</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/mvc3-subgridrowexpanded-action-not-firing#p27490</guid>
        	        	<description><![CDATA[<p>OK, So I have finally answwer my own question!</p>
<p>The BankLists controller Action did not contain a properly generated jqGridResponse, and hence somehow the jqGrid knew this and did not even call it ? (I&#39;m guessing at the cause a little - I corrected the bankLinks action and it now works!)</p></p>
]]></description>
        	        	<pubDate>Fri, 05 Oct 2012 18:50:19 +0300</pubDate>
        </item>
        <item>
        	<title>AHumphries on MVC3 subGridRowExpanded action not firing</title>
        	<link>http://www.trirand.com/blog/?page_id=393/help/mvc3-subgridrowexpanded-action-not-firing#p27488</link>
        	<category>Help</category>
        	<guid isPermaLink="true">http://www.trirand.com/blog/?page_id=393/help/mvc3-subgridrowexpanded-action-not-firing#p27488</guid>
        	        	<description><![CDATA[<p>Hi, Im developing an MVC3 application, and I am trying to use the subGridRowExpanded to nest a jqGrid inside another (so I can use the formatter amongst other things), however, I cannot get the Subgrid to fire the Controller Event that populates The data.</p>
<p>Any Help On this is greatly appreciated!</p>
</p>
<p>The below code runs the main grid, populates it with Data from the Customers Action URL, but does not even fire the &#39;BankLinks&#39; ActionURL</p>
<p>Can anyone tell me why?</p>
</p>
<p>Thanks in advance</p>
<p>Andrew.</p>
</p>
<p><span style="color: #ff0000;"><strong><span style="text-decoration: underline;">My Index.cshtml</span></strong></span></p>
<p>@{</p>
<p><span style="white-space:pre"> </span>ViewBag.Title = "Index";</p>
<p>}</p>
</p>
<p>&#60;h2&#62;@ViewBag.Message&#60;/h2&#62;</p>
<p>&#60;div id="content"&#62;</p>
<p><span style="white-space:pre"> </span>&#60;div id="content-left"&#62;</p>
<p><span style="white-space:pre"> </span>@Html.Partial("SearchPanel")</p>
<p><span style="white-space:pre"> </span>&#60;/div&#62;</p>
<p><span style="white-space:pre"> </span>&#60;div id="content-main"&#62;</p>
<p><span style="white-space:pre"> </span>&#60;table id="jpgCustomers" cellpadding="0" cellspacing="0"&#62;&#60;/table&#62;</p>
<p><span style="white-space:pre"> </span>&#60;div id="jpgpCustomers" style="text-align:center;"&#62;&#60;/div&#62;</p>
<p><span style="white-space:pre"> </span>&#60;/div&#62;</p>
<p>&#60;/div&#62;</p>
<p>@section JavaScript</p>
<p>{</p>
<p>&#60;script type="text/javascript"&#62;</p>
<p>$(document).ready(function ()</p>
<p>{</p>
<p><span style="white-space:pre"> </span>$(&#39;#jpgCustomers&#39;).jqGrid({</p>
<p><span style="white-space:pre"> </span>//url from wich data should be requested</p>
<p><span style="white-space:pre"> </span>url: &#39;@Url.Action("Customers")&#39;,</p>
<p><span style="white-space: pre; "> </span>//type of data</p>
<p><span style="white-space:pre"> </span>datatype: &#39;json&#39;,</p>
<p><span style="white-space:pre"> </span>//url access method type</p>
<p><span style="white-space:pre"> </span>mtype: &#39;POST&#39;,</p>
<p><span style="white-space:pre"> </span>//columns names</p>
<p><span style="white-space:pre"><span style="white-space: pre;"> </span> </span>colNames: [&#39;Name&#39;, &#39;FullName&#39;, &#39;SFTP Enabled&#39;, &#39;IsTranbase&#39;],</p>
<p><span style="white-space:pre"> </span>//columns model</p>
<p><span style="white-space:pre"> </span>colModel: [</p>
<p><span style="white-space:pre"> </span>{ name: &#39;LogonName&#39;, index: &#39;LogonName&#39;, align: &#39;left&#39; },</p>
<p><span style="white-space:pre"> </span>{ name: &#39;FullName&#39;, index: &#39;FullName&#39;, align: &#39;left&#39; },</p>
<p><span style="white-space:pre"> </span>{ name: &#39;Enabled&#39;, index: &#39;Enabled&#39;, align: &#39;left&#39; },</p>
<p><span style="white-space:pre"> </span>{ name: &#39;IsTran&#39;, index: &#39;IsTranbase&#39;, align: &#39;left&#39; }</p>
<p><span style="white-space:pre"> </span>],</p>
<p><span style="white-space:pre"> </span>//pager for grid</p>
<p><span style="white-space:pre"> </span>pager: $(&#39;#jpgpCustomers&#39;),</p>
<p><span> </span>//number of rows per page</p>
<p><span style="white-space:pre"> </span>rowNum: 10,</p>
<p><span style="white-space:pre"> </span>//initial sorting column</p>
<p><span style="white-space:pre"> </span>sortname: &#39;FullName&#39;,</p>
<p><span style="white-space:pre"> </span>//initial sorting direction</p>
<p><span style="white-space:pre"> </span>sortorder: &#39;asc&#39;,</p>
<p><span style="white-space:pre"> </span>//we want to display total records count</p>
<p><span style="white-space:pre"> </span>viewrecords: true,</p>
<p><span style="white-space:pre"> </span>//grid height</p>
<p><span style="white-space:pre"> </span>height: &#39;100%&#39;,</p>
<p><span style="white-space:pre"> </span>//subgrid</p>
<p><span style="white-space:pre"> </span>subGrid: true,</p>
<p><span style="white-space:pre"> </span>//subrid model</p>
<p><span style="white-space:pre"> </span>subGridRowExpanded: function(subgrid_id, row_id) {</p>
<p><span style="white-space:pre"> </span>var subgrid_table_id, pager_id;</p>
<p><span style="white-space:pre"> </span>subgrid_table_id = subgrid_id+"_t";</p>
<p><span style="white-space:pre"> </span>pager_id = "p_"+subgrid_table_id;</p>
<p><span style="white-space:pre"> </span>$("#"+subgrid_id).html("&#60;table id=&#39;"+subgrid_table_id+"&#39; class=&#39;scroll&#39;&#62;&#60;/table&#62;&#60;div&#160;id=&#39;"+pager_id+"&#39;class=&#39;scroll&#39;&#62;&#60;/div&#62;");</p>
<p><span style="white-space:pre"> </span>$("#"+subgrid_table_id).jqGrid({</p>
<p><span style="white-space:pre"> </span>url: &#39;@Url.Action("BankLinks")&#39;,</p>
<p><span style="white-space:pre"> </span>datatype: &#39;json&#39;,</p>
<p><span style="white-space:pre"> </span>mtype: &#39;POST&#39;,</p>
<p><span style="white-space:pre"> </span>colNames: [&#39;Bank&#39;, &#39;Folder&#39;, &#39;Enabled&#39;],</p>
<p><span style="white-space:pre"> </span>colModel:[</p>
<p><span style="white-space:pre"> </span>{name:"Bank",index:"Bank",width:80,key:true},</p>
<p><span style="white-space:pre"> </span>{name:"Folder",index:"Folder",width:130},</p>
<p><span style="white-space:pre"> </span>{name:"Enabled",index:"Enabled",width:70,align:"left"}</p>
<p><span style="white-space:pre"> </span>],</p>
<p><span style="white-space:pre"> </span>rowNum:20,</p>
<p><span style="white-space:pre"> </span>pager: pager_id,</p>
<p><span style="white-space:pre"> </span>sortname: &#39;Bank&#39;,</p>
<p><span style="white-space:pre"> </span>sortorder: "asc",</p>
<p><span style="white-space:pre"> </span>viewrecords: true,</p>
<p><span style="white-space:pre"> </span>height: &#39;100%&#39;</p>
<p><span style="white-space:pre"> </span>});</p>
<p><span style="white-space:pre"> </span>$("#"+subgrid_table_id).jqGrid(&#39;navGrid&#39;,"#"+pager_id,{edit:false,add:false,del:false})</p>
<p><span style="white-space:pre"> </span>},</p>
<p><span style="white-space:pre"> </span>});</p>
<p>});</p>
<p>&#60;/script&#62;</p>
<p>}</p>
</p>
<p>and my<strong><span style="text-decoration: underline;"><span style="color: #ff0000;"> Controllier Actions:</span></span></strong></p>
<p><strong>[AcceptVerbs(HttpVerbs.Post)]</strong></p>
<p><strong>public ActionResult Customers(JqGridRequest request)</strong></p>
<p>{</p>
<p><span style="white-space:pre"> </span>ISession session = NHibernateHelper.GetCurrentSession();</p>
<p><span style="white-space: pre; "> </span>IEnumerable&#60;Customer&#62; customers = session.QueryOver&#60;Customer&#62;().List().Skip&#60;Customer&#62;(0).Take&#60;Customer&#62;(request.RecordsCount);</p>
</p>
<p><span style="white-space:pre"> </span>int totalRecords = customers.Count();</p>
</p>
<p><span style="white-space:pre"> </span>//Prepare JqGridData instance</p>
<p><span style="white-space:pre"> </span>JqGridResponse response = new JqGridResponse()</p>
<p><span style="white-space:pre"> </span>{</p>
<p><span style="white-space:pre"> </span>//Total pages count</p>
<p><span style="white-space:pre"> </span>TotalPagesCount = (int)Math.Ceiling((float)totalRecords / (float)request.RecordsCount),</p>
<p><span style="white-space:pre"> </span>//Page number</p>
<p><span style="white-space:pre"> </span>PageIndex = request.PageIndex,</p>
<p><span style="white-space:pre"> </span>//Total records count</p>
<p><span style="white-space:pre"> </span>TotalRecordsCount = totalRecords</p>
<p><span style="white-space:pre"> </span>};</p>
<p><span style="white-space:pre"> </span>//Table with rows data</p>
<p><span style="white-space:pre"> </span>foreach (Customer customer in customers)</p>
<p><span style="white-space:pre"> </span>{</p>
<p><span style="white-space:pre"> </span>response.Records.Add(new JqGridRecord(Convert.ToString(customer.Id), new List&#60;object&#62;()</p>
<p><span style="white-space:pre"> </span>{</p>
<p><span style="white-space:pre"> </span>customer.FtpDetails.LogonName,</p>
<p><span style="white-space:pre"> </span>customer.FtpDetails.FullName,</p>
<p><span style="white-space:pre"> </span>customer.FtpDetails.Enabled,</p>
<p><span style="white-space:pre"> </span>customer.IsTran</p>
<p><span style="white-space:pre"> </span>}));</p>
<p><span style="white-space:pre"> </span>}</p>
</p>
<p><span style="white-space:pre"> </span>//Return data as json</p>
<p><span style="white-space:pre"> </span>return new JqGridJsonResult() { Data = response };</p>
<p>}</p>
</p>
<p><strong>[AcceptVerbs(HttpVerbs.Post)]</strong></p>
<p><strong>public ActionResult BankLinks(JqGridRequest request)</strong></p>
<p>{</p>
<p><span style="white-space:pre"> </span>ISession session = NHibernateHelper.GetCurrentSession();</p>
</p>
<p><span style="white-space:pre"> </span>JqGridResponse response = new JqGridResponse();</p>
</p>
<p><span style="white-space:pre"> </span>Customer customer = session.Get&#60;Customer&#62;(14);</p>
<p><span style="white-space:pre"> </span>foreach (Bank bank in customer.Banks.ToList&#60;Bank&#62;())</p>
<p><span style="white-space:pre"> </span>{</p>
<p><span style="white-space:pre"> </span>CustomerBank bankLink = session.QueryOver&#60;CustomerBank&#62;().Where(x =&#62; x.BankId == bank.Id).Where(y =&#62; y.CustomerId == customer.Id).List&#60;CustomerBank&#62;().FirstOrDefault();</p>
</p>
<p><span style="white-space: pre;"> </span>response.Records.Add(new JqGridRecord(null, new List&#60;object&#62;()</p>
<p><span style="white-space: pre;"> </span>{</p>
<p><span style="white-space: pre;"> </span>bank.BankCode,</p>
<p><span style="white-space: pre;"> </span>bank.Folder,</p>
<p><span style="white-space: pre;"> </span>1</p>
<p><span style="white-space: pre;"> </span>}));</p>
<p><span style="white-space: pre;"> </span>}</p>
</p>
<p><span style="white-space: pre;"> </span>return new JqGridJsonResult() { Data = response };</p>
<p>}</p>
]]></description>
        	        	<pubDate>Fri, 05 Oct 2012 17:35:08 +0300</pubDate>
        </item>
</channel>
</rss>