Intersoft WebGrid Documentation
OnInitializeLayout Method
See Also  Example Send Feedback
ISNet.WebUI.WebGrid Namespace > WebGrid Class : OnInitializeLayout Method






layout
A reference to the LayoutSet object
Invoked when the Grid's layout needs to be initialized during data binding. You can write the codes to dynamically add Columns, GroupedColumns, or other objects in this event.

Syntax

Visual Basic (Declaration) 
Public Overridable Function OnInitializeLayout( _
   ByVal layout As LayoutSet _
) As Boolean
Visual Basic (Usage)Copy Code
Dim instance As WebGrid
Dim layout As LayoutSet
Dim value As Boolean
 
value = instance.OnInitializeLayout(layout)
C# 
public virtual bool OnInitializeLayout( 
   LayoutSet layout
)
Delphi 
public function OnInitializeLayout( 
    layout: LayoutSet
): Boolean; virtual; 
JScript 
public function OnInitializeLayout( 
   layout : LayoutSet
) : boolean;
Managed Extensions for C++ 
public: virtual bool OnInitializeLayout( 
   LayoutSet* layout
) 
C++/CLI 
public:
virtual bool OnInitializeLayout( 
   LayoutSet^ layout
) 

Parameters

layout
A reference to the LayoutSet object

Return Value

Returns ReturnValue. Event will be cancelled when ReturnValue is False.

Example

The codes below are created to configure the root table and its child tables along with all columns at InitializeLayout event.
C#Copy Code
private void WebGrid1_InitializeLayout(object sender, ISNet.WebUI.WebGrid.LayoutEventArgs e)
{
   WebGrid1.RootTable = null;
   WebGrid1.RootTable.Columns.Clear(); 
   WebGrid1.RootTable.ChildTables.Clear(); 
   WebGrid1.RootTable.DataMember = "Customers"; 
   WebGrid1.RootTable.DataKeyField = "CustomerID"; 
   foreach(string col in UseProfileRoot) 
   { 
       WebGrid1.RootTable.Columns.Add(new WebGridColumn(col, col, col)); 
   }

   WebGridTable childTable = new WebGridTable(); 
   childTable.DataMember = "Orders"; 
   childTable.DataKeyField = "OrderID"; 
   foreach(string col in UseProfileChild) 
   {
       childTable.Columns.Add(new WebGridColumn(col, col, col)); 
   } 
   WebGrid1.RootTable.ChildTables.Add(childTable); 
}

Remarks

InitializeLayout event is originally designed to let developers programmatically configure static WebGrid's behavior, appearance, look and feel, styles etc. It is quite easy to configure the layout by just using e.Layout , since in this event developers could obtained the LayoutSetting properties from LayoutEventArgs. No dynamic objects or data related settings should be placed here especially if those objects are created during runtime.

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.