Intersoft WebGrid Documentation
WebGridTable Class
Members  Example  See Also  Send Feedback
ISNet.WebUI.WebGrid Namespace : WebGridTable Class






WebGridTable is the cental object of WebGrid control. It is used as the RootTable object that represents the top most level of WebGridTableCollection object.

Object Model

WebGridTable Class

Syntax

Visual Basic (Declaration) 
<DescriptionAttribute()>
<PersistenceModeAttribute(PersistenceMode.InnerProperty)>
<SerializableAttribute()>
Public Class WebGridTable 
   Inherits ISNet.WebUI.NamedObjectBase
   Implements ISNet.ICopyable, ISNet.IResetable, ISNet.Serialization.BinarySerialization.IBinarySerialize, ISNet.Serialization.XmlSerialization.ICustomXmlSerializer, ISNet.WebUI.INamedObject 
Visual Basic (Usage)Copy Code
Dim instance As WebGridTable
C# 
[DescriptionAttribute()]
[PersistenceModeAttribute(PersistenceMode.InnerProperty)]
[SerializableAttribute()]
public class WebGridTable : ISNet.WebUI.NamedObjectBase, ISNet.ICopyable, ISNet.IResetable, ISNet.Serialization.BinarySerialization.IBinarySerialize, ISNet.Serialization.XmlSerialization.ICustomXmlSerializer, ISNet.WebUI.INamedObject  
Delphi 
public class WebGridTable = class(ISNet.WebUI.NamedObjectBase, ISNet.ICopyable, ISNet.IResetable, ISNet.Serialization.BinarySerialization.IBinarySerialize, ISNet.Serialization.XmlSerialization.ICustomXmlSerializer, ISNet.WebUI.INamedObject)
JScript 
DescriptionAttribute()
PersistenceModeAttribute(PersistenceMode.InnerProperty)
SerializableAttribute()
public class WebGridTable extends ISNet.WebUI.NamedObjectBase implements ISNet.ICopyable, ISNet.IResetable, ISNet.Serialization.BinarySerialization.IBinarySerialize, ISNet.Serialization.XmlSerialization.ICustomXmlSerializer, ISNet.WebUI.INamedObject 
Managed Extensions for C++ 
[DescriptionAttribute()]
[PersistenceModeAttribute(PersistenceMode.InnerProperty)]
[SerializableAttribute()]
public __gc class WebGridTable : public ISNet.WebUI.NamedObjectBase, ISNet.ICopyable, ISNet.IResetable, ISNet.Serialization.BinarySerialization.IBinarySerialize, ISNet.Serialization.XmlSerialization.ICustomXmlSerializer, ISNet.WebUI.INamedObject  
C++/CLI 
[DescriptionAttribute()]
[PersistenceModeAttribute(PersistenceMode.InnerProperty)]
[SerializableAttribute()]
public ref class WebGridTable : public ISNet.WebUI.NamedObjectBase, ISNet.ICopyable, ISNet.IResetable, ISNet.Serialization.BinarySerialization.IBinarySerialize, ISNet.Serialization.XmlSerialization.ICustomXmlSerializer, ISNet.WebUI.INamedObject  

Example

The following example shows you how to create WebGridTable programmatically and can be updated.
C#Copy Code
private void WebGrid1_InitializeDataSource(object sender, ISNet.WebUI.WebGrid.DataSourceEventArgs e)
{
    DataSet ds = new DataSet();
    oleDbDataAdapter1.Fill(ds, "Customers");
    oleDbDataAdapter2.Fill(ds, "Orders");
    oleDbDataAdapter3.Fill(ds, "OrderDetails");
    ds.Relations.Add("rel1", ds.Tables["Customers"].Columns["CustomerID"], ds.Tables["Orders"].Columns["CustomerID"]);
    ds.Relations.Add("rel2", ds.Tables["Orders"].Columns["OrderID"], ds.Tables["OrderDetails"].Columns["OrderID"]);
    e.DataSource = ds;
}

private void WebGrid1_InitializeLayout(object sender, ISNet.WebUI.WebGrid.LayoutEventArgs e)
{ 
    e.Layout.AllowEdit = Edit.Yes;
    e.Layout.Hierarchical = true;
    e.Layout.AllowAddNew = AddNew.Yes;

    if(!IsPostBack)
    {
       WebGrid1.RootTable = CreateWGTable("Customers", "CustomerID");
       string[] colNames = {"CustomerID", "ContactName"};
       PopulateWGTable(WebGrid1.RootTable, colNames);

       WebGrid1.RootTable.ChildTables.Add( CreateWGTable("Orders", "OrderID") );
       string[] colNamesChild = {"shipVia","OrderID", "OrderDate","CustomerID"};
       PopulateWGTable(WebGrid1.GetTableByName("Orders"), colNamesChild);
    
       WebGrid1.RootTable.ChildTables[0].ChildTables.Add( CreateWGTable("OrderDetails", "OrderID") );
       string[] colNamesChild2 = {"OrderID", "ProductID"};
       PopulateWGTable(WebGrid1.GetTableByName("OrderDetails"), colNamesChild2);
    
    }
}

private WebGridTable CreateWGTable(string dataMember, string dataKeyField)
{
    WebGridTable tbl = new WebGridTable();
    tbl.DataMember = tbl.Caption = dataMember;
    tbl.DataKeyField = dataKeyField;
    return tbl;
}

private void PopulateWGTable(WebGridTable tbl, string[] colNames)
{
    WebGridColumn col;
    foreach(string s in colNames)
    {
       col = new WebGridColumn(s, s, s);
       tbl.Columns.Add(col);
    }
  
}

private void WebGrid1_UpdateRow(object sender, ISNet.WebUI.WebGrid.RowEventArgs e)
{
     DataSet ds = (DataSet)WebGrid1.DataSource;   
     // update the deleted row using proper dataadapter for each datatable.   
     if (e.Row.Table.DataMember == "Customers")    
     {
        oleDbDataAdapter1.Update(ds.Tables["Customers"]);   
     }   
     else if (e.Row.Table.DataMember == "Orders")    
     {    
     oleDbDataAdapter2.Update(ds.Tables["Orders"]);  
     }   
     else   
     {    
     oleDbDataAdapter3.Update(ds.Tables["Order Details"]);   
     }
}

Remarks

The RootTable can contains unlimited WebGridTable when work in Hierarchical mode. The object has many properties that allow users to customize the appearance, look, and behavior of the Table.

The hierarchical object model is completely defined in ChildTables which type is WebGridTablesCollection. Since WebGridTable is the central object in WebGrid, the ChildTables object is included in WebGridTable object. The ChildTables itself is a collection of WebGridTable objects, those structure made up the Hierarchical object model. 

WebGridTable consists of WebGridRowCollection and WebGridColumnCollection which are primary objects that is used to render a WebGrid control. WebGridTable can also contain multiple WebGridTable objects contained in ChildTables which is used to represent hierarchical grid.

WebGridTable contains numerous properties and settings that control the behavior of each WebGridTable independently such as AllowAddNew, AllowColumnMove, AllowSorting, AllowDelete and so on. Developers can either set these properties on design time or runtime. It also contains collection of GroupedColumns, SortedColumns and FilteredColumns in which you can add or remove items on either design time or runtime. The other features in WebGridTable include PreviewRowSettings and ColumnSetSettings 

One important feature in WebGridTable is SelfReferenceTable. SelfReference makes a simple flat grid becomes hierarchical. The SelfReference feature is unique, since that it is implemented as an entirely new feature and therefore does not sacrifice any other features. Therefore you can still enable normal Hierarchical mode along with the SelfReferencing feature, enabling sophisticated and never-possible-before scenarios to be implemented easily. You can create Self Reference Table by simply bind the WebGridTable and set the SelfReferencingSettings in Designer.

The WebGridTable has built-in methods to retrieve columns and hierarchical childTable's structure based on the assigned DataSource and its DataMember. However, it is always the best practice to have all columns defined at design time as you can customize many appearance and behavior settings of the columns.

It is recommended that WebGridTable's DataMember or Name doesn't contain characters such as space, _ (underscore), - (minus), or other unusual characters.

Unbound Mode

WebGrid.NET Enterprise 5.0 allows you to configure Hierarchical child tables in Unbound mode. In previous versions, WebGrid only support databound mode to be used in Hierarchical feature. To simulate Unbound mode in previous versions, you usually create a temporary DataSet and the DataTables and map them through DataRelation.

In this new version, you no longer need temporary DataSet or workarounds in order to configure hierarchical Grid in Unbound mode. WebGrid 5.0 supports pure Unbound mode through server side object model. Please note that when the Grid is operating in Unbound mode, all data-bound features (such as sorting, grouping, etc.) should not be enabled. For more information, please read Walkthrough: Create Unbound WebGrid with Hierarchical enabled.

Inheritance Hierarchy

System.Object
   ISNet.WebUI.WebUIBaseClass
      ISNet.WebUI.NamedObjectBase
         ISNet.WebUI.WebGrid.WebGridTable

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.