Intersoft WebGrid Documentation
IHierarchicalList Interface
Members  Example  See Also  Send Feedback
ISNet.WebUI.WebGrid Namespace : IHierarchicalList Interface






IHierarchicalList interface, required to support hierarchichal objects binding in WebGrid.NET Enterprise V4.0.

Syntax

Visual Basic (Declaration) 
Public Interface IHierarchicalList 
Visual Basic (Usage)Copy Code
Dim instance As IHierarchicalList
C# 
public interface IHierarchicalList 
Delphi 
public interface IHierarchicalList 
JScript 
public interface IHierarchicalList 
Managed Extensions for C++ 
public __gc __interface IHierarchicalList 
C++/CLI 
public interface class IHierarchicalList 

Example

 

The following is sample code for IHierarchicalList Implementation for Flat Collection.
C#Copy Code
public class CustomerCollection : System.Collections.CollectionBase, IHierarchicalList
{
    public void Add(Customer aCustomer)
    {
        aCustomer.Owner = this;
        List.Add(aCustomer);
    }
        
    public bool Remove(int index)
    {
        // Check to see if there is a customer at the supplied index.
        if (index > Count - 1 || index < 0)
        {
            return false;
        }
        else
        {
            List.RemoveAt(index);
            return true;
        }
    }
     
    public void Remove(Customer cust)
    {
        List.Remove(cust);
    }
    
    public Customer Item(int Index)
    {
        return (Customer) List[Index];
    }
    
    public Customer FindByID(string customerID)
    {
        foreach (Customer c in this.InnerList)
        {
            if (c.CustomerID == customerID) return c;
        }
        return null;
    }
    
    #region IHierarchicalList Members
    
    public Type ItemType
    {
        get
        {
            return typeof(Customer);
        }
    }
    
    #endregion
}
The following is sample code for data binding.
C#Copy Code
private void WebGrid1_InitializeDataSource(object sender,
ISNet.WebUI.WebGrid.DataSourceEventArgs e)
{
    CustomerCollection customers = DataLayer.GetCustomers();
    
    // populate order to all customers
    foreach (Customer cust in customers)
    {
        cust.PopulateOrders();
    }
    e.DataSource = customers;
}

Remarks

WebGrid.NET 4.0 provides multiple ways to display binding flat collection. They are Direct Binding and IHierarchicalList Implementation.

In IHierarchicalList Implementation, V4.0 introduces a more powerful collection handling which is originally designed for Hierarchical Collection. This new implementation solves the problems on limitation over the traditional implementation, such as the usage of Attributes to easily control the Table's Name, Column's Caption and Visibility of a public property and more.

Due to broad scenarios support of hierarchical collections, the final version of 4.0 has opened the support to use similar implementation for Flat Collection. To use the new implementation for Flat collection, you only need to implement the IHierarchicalList interface.

Hierarchical property of the LayoutSettings is required to be set to False for Flat Collection support using new implementation.

Requirements

Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family

See Also

©2012 Intersoft Solutions Corp. All Rights Reserved.