I have two classes:
- DealCashFlowBC
- CusipCashFlowBC
A deal can have information of multiple cusips that's why we have a list of type CusipCashflowBC in DealCashFlowBC.
Now the problem is:
- I need to bind these columns dynamically in kendo grid
- In my case, I did data binding but column headers are not there.
Here is the code:
public class DealCashFlowBC
{
public string DealName { get; set; }
public int Period { get; set; }
public DateTime Date { get; set; }
public int NetInterest { get; set; }
public int PeriodicASER { get; set; }
public int AdjustedNetInterest { get; set; }
public int TotalPrincipal { get; set; }
public int Balance { get; set; }
public int PrincipalLoss { get; set; }
public List<CusipCashFlowBC> CCFBC { get; set; }
}
public class CusipCashFlowBC
{
public string Cusip { get; set; }
public int Period { get; set; }
public string ClassName { get; set; }
public double? Interest { get; set; }
public double Principal { get; set; }
public double Loss { get; set; }
public double EndBal { get; set; }
public double Penalty { get; set; }
public double AccumulatedShortfall { get; set; }
}
Grid Code:
.Columns(columns =>
{
columns.Bound(e => e.Period).Title("Period").Width(100);
columns.Bound(e => e.Date).Title("Settlement Date").Width(100);
columns.Bound(e => e.NetInterest).Title("Net Interest @ original terms").Width(80);
columns.Bound(e => e.PeriodicASER).Title("Periodic ASER").Width(100);
columns.Bound(e => e.AdjustedNetInterest).Title("Adjusted Net Interest").Width(100);
columns.Bound(e => e.TotalPrincipal).Title("Total Principal").Width(100);
columns.Bound(e => e.Balance).Title("Balance").Width(100);
columns.Bound(e => e.PrincipalLoss).Title("Principal Loss").Width(100);
columns.Template(e => { }).ClientTemplate("#=iterate(CCFBC)#").Title("CCFBC");
Javascript:
function iterate(ReportList) {
var template = "";
for (var i = 0; i < ReportList.length; i++) {
template = template + "<td role='gridcell'>" + ReportList[i].Cusip + "</td><td role='gridcell'>" + ReportList[i].Period + "</td><td role='gridcell'>" + ReportList[i].ClassName + "</td><td role='gridcell'>" + ReportList[i].Principal + "</td>";
}
return template;
}
Problem: Not able to get headers for dynamic columns
I want header for those dynamic column, generating from client Template iteration.