Hi,
I have a Parent object (Budget class) with collection (implements IEnumerable) of its child elements (Documents).
class Budget {...IList<Document> documents;public IList<Document> Documents { get { return documents; } };...}
class Document {...string name;public string Name { get { return name; } }}I try to bind a collection of budget items to the grid so that the documents appear in the next child band. In the code behind I wrote:
protected void MainGrid_InitializeBand(object sender, Infragistics.WebUI.UltraWebGrid.BandEventArgs e) { if (e.Band == MainGrid.Bands[1]) { e.Band.ChildBandColumn = "Documents"; } }
Am I doing something wrong here? Could you please provide asp code that I should use in my MainGrid declaration so that this code starts working? Should I have 2 Bands elements declared or only one? May I add columns to this bands and how should they be declared?Thanks in advance for your help,Sebastian
You don't really need to be handling the InitializeBand to do what you want. You just need an IEnumerable on the Parent object.
There was a bug, resolved but I can't remember how long ago that if the first parent object did not have a child object (or members in the child object) that it would not bind to that level. But it is resolved now (or in the next hotfix).
Try out this sample. Running it should result in the image attached.
public class Docs{ public string Name { get; set; }}public class Budget{ public string BName { get; set; } public List<Docs> Dox { get; set; }}public partial class _Default : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { this.UltraWebGrid1.DisplayLayout.ViewType = Infragistics.WebUI.UltraWebGrid.ViewType.Hierarchical; List<Budget> list = new List<Budget>(); Budget b1 = new Budget() { BName = "1999", Dox = new List<Docs>() }; list.Add(b1); Budget b = new Budget() { BName = "2000", Dox = new List<Docs>() }; Docs d = new Docs() { Name = "Bob" }; b.Dox.Add(d); list.Add(b); this.UltraWebGrid1.DataSource = list; this.UltraWebGrid1.DataBind(); }}
Jaimir G.
If memory serves you would need to set the ChildBandColumn off the band object to the name of the property that you want the child band to be derived from
You would do this at Design time or (maybe) during the InitializeBand event for band zero.
OMG this totally fixed my problem. I have a collection of objects that each have their own child collections. Using the ChildBandColumn I was able to tell each parent grid row which child collection to display as its children. I am so happy about this.
Now, If they could just allow multiple sibling bands to have different objects bound.