Hello,
In my class I have a List of object, like:
public class Person {
public string Name { get; set }
public List<Salary> monthSalary { get; set; }
}
And
public class Salary {
public int Month { get; set; }
public decimal Salary { get; set; }
}
In my controller, I populate the Person object so that it always has 12 items in the monthSalay List, one for each month.
I'm binding this to my table by doing
for(int i = 1; i <= 12; i++)
{
col.HeaderText(i).Field("monthSalary." + i - 1 + ".Salary").Add();
}
Is this the only solution to archieve this?
Anyways, it works, but I'd like to add a template for the column like:
col.HeaderText(i).Field("monthSalary." + i - 1 + ".Salary").Template("<span class='niceClassForSalary'>${monthSalary." + i + ".Salary}</span>").Add();
If I do this, the grid shows nothing. Is there a way to access complex object in template?
Thank you