Forum


17:35

05/10/2012

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.
Any Help On this is greatly appreciated!
The below code runs the main grid, populates it with Data from the Customers Action URL, but does not even fire the 'BankLinks' ActionURL
Can anyone tell me why?
Thanks in advance
Andrew.
My Index.cshtml
@{
ViewBag.Title = "Index";
}
<h2>@ViewBag.Message</h2>
<div id="content">
<div id="content-left">
@Html.Partial("SearchPanel")
</div>
<div id="content-main">
<table id="jpgCustomers" cellpadding="0" cellspacing="0"></table>
<div id="jpgpCustomers" style="text-align:center;"></div>
</div>
</div>
@section JavaScript
{
<script type="text/javascript">
$(document).ready(function ()
{
$('#jpgCustomers').jqGrid({
//url from wich data should be requested
url: '@Url.Action("Customers")',
//type of data
datatype: 'json',
//url access method type
mtype: 'POST',
//columns names
colNames: ['Name', 'FullName', 'SFTP Enabled', 'IsTranbase'],
//columns model
colModel: [
{ name: 'LogonName', index: 'LogonName', align: 'left' },
{ name: 'FullName', index: 'FullName', align: 'left' },
{ name: 'Enabled', index: 'Enabled', align: 'left' },
{ name: 'IsTran', index: 'IsTranbase', align: 'left' }
],
//pager for grid
pager: $('#jpgpCustomers'),
//number of rows per page
rowNum: 10,
//initial sorting column
sortname: 'FullName',
//initial sorting direction
sortorder: 'asc',
//we want to display total records count
viewrecords: true,
//grid height
height: '100%',
//subgrid
subGrid: true,
//subrid model
subGridRowExpanded: function(subgrid_id, row_id) {
var subgrid_table_id, pager_id;
subgrid_table_id = subgrid_id+"_t";
pager_id = "p_"+subgrid_table_id;
$("#"+subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table><div id='"+pager_id+"'class='scroll'></div>");
$("#"+subgrid_table_id).jqGrid({
url: '@Url.Action("BankLinks")',
datatype: 'json',
mtype: 'POST',
colNames: ['Bank', 'Folder', 'Enabled'],
colModel:[
{name:"Bank",index:"Bank",width:80,key:true},
{name:"Folder",index:"Folder",width:130},
{name:"Enabled",index:"Enabled",width:70,align:"left"}
],
rowNum:20,
pager: pager_id,
sortname: 'Bank',
sortorder: "asc",
viewrecords: true,
height: '100%'
});
$("#"+subgrid_table_id).jqGrid('navGrid',"#"+pager_id,{edit:false,add:false,del:false})
},
});
});
</script>
}
and my Controllier Actions:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Customers(JqGridRequest request)
{
ISession session = NHibernateHelper.GetCurrentSession();
IEnumerable<Customer> customers = session.QueryOver<Customer>().List().Skip<Customer>(0).Take<Customer>(request.RecordsCount);
int totalRecords = customers.Count();
//Prepare JqGridData instance
JqGridResponse response = new JqGridResponse()
{
//Total pages count
TotalPagesCount = (int)Math.Ceiling((float)totalRecords / (float)request.RecordsCount),
//Page number
PageIndex = request.PageIndex,
//Total records count
TotalRecordsCount = totalRecords
};
//Table with rows data
foreach (Customer customer in customers)
{
response.Records.Add(new JqGridRecord(Convert.ToString(customer.Id), new List<object>()
{
customer.FtpDetails.LogonName,
customer.FtpDetails.FullName,
customer.FtpDetails.Enabled,
customer.IsTran
}));
}
//Return data as json
return new JqGridJsonResult() { Data = response };
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult BankLinks(JqGridRequest request)
{
ISession session = NHibernateHelper.GetCurrentSession();
JqGridResponse response = new JqGridResponse();
Customer customer = session.Get<Customer>(14);
foreach (Bank bank in customer.Banks.ToList<Bank>())
{
CustomerBank bankLink = session.QueryOver<CustomerBank>().Where(x => x.BankId == bank.Id).Where(y => y.CustomerId == customer.Id).List<CustomerBank>().FirstOrDefault();
response.Records.Add(new JqGridRecord(null, new List<object>()
{
bank.BankCode,
bank.Folder,
1
}));
}
return new JqGridJsonResult() { Data = response };
}
Most Users Ever Online: 715
Currently Online:
45 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66