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






childTable
dataSource
The reference to the dataSource object.
parentConstraints
The reference to the ParentConstraints.
customReqData
The reference to the custom request data send by client's request.
Invoked when childTable's dataSource need to be initialized.

Syntax

Visual Basic (Declaration) 
Public Overridable Function OnInitializeChildTableDataSource( _
   ByVal childTable As WebGridTable, _
   ByVal dataSource As Object, _
   ByVal parentConstraints As String, _
   ByVal customReqData As String _
) As Boolean
Visual Basic (Usage)Copy Code
Dim instance As WebGrid
Dim childTable As WebGridTable
Dim dataSource As Object
Dim parentConstraints As String
Dim customReqData As String
Dim value As Boolean
 
value = instance.OnInitializeChildTableDataSource(childTable, dataSource, parentConstraints, customReqData)
C# 
public virtual bool OnInitializeChildTableDataSource( 
   WebGridTable childTable,
   object dataSource,
   string parentConstraints,
   string customReqData
)
Delphi 
public function OnInitializeChildTableDataSource( 
    childTable: WebGridTable;
    dataSource: TObject;
    parentConstraints: String;
    customReqData: String
): Boolean; virtual; 
JScript 
public function OnInitializeChildTableDataSource( 
   childTable : WebGridTable,
   dataSource : Object,
   parentConstraints : String,
   customReqData : String
) : boolean;
Managed Extensions for C++ 
public: virtual bool OnInitializeChildTableDataSource( 
   WebGridTable* childTable,
   Object* dataSource,
   string* parentConstraints,
   string* customReqData
) 
C++/CLI 
public:
virtual bool OnInitializeChildTableDataSource( 
   WebGridTable^ childTable,
   Object^ dataSource,
   String^ parentConstraints,
   String^ customReqData
) 

Parameters

childTable
dataSource
The reference to the dataSource object.
parentConstraints
The reference to the ParentConstraints.
customReqData
The reference to the custom request data send by client's request.

Return Value

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

Example

 

Remarks

WebGrid was built with scalability and performance as its key design consideration. It is specially designed to work best in enterprise-class environment in which each childTables contains very large dataSource.

WebGrid provides a true "Load On Demand" architecture in which developers has full control over the childTable's dataSource. Developers can decide to load only root level's dataSource on the first page load and then load the childTable's dataSource only on when users click on [+] sign to expand childTable's rows.

You can take advantage of the provided ParentConstraints parameter which is an XML string that contains a pair of constraints and values of the ParentRow; to filter and dynamically load the childTable's dataSource based on the constraints. This enables you to fully control the server's workload and dramatically increases overall performance.

By default, WebGrid is able to handle and load ChildTable's rows automatically based on correct constrains without any additional codes. However, you can choose to override and write your own codes in this event.

 

Load child tables data source on demand

WebGrid.NET 5.0 Enterprise serves as pure User Interface control since it is supported with datasource control support. That means WebGrid no longer handle datasource level manipulation. Instead, WebGrid simply connects to a datasource control which primarily performing data retrieval and data manipulation. With this new concept, WebGrid simply displays a valid datasource that has been successfully retrieved by datasource control. 

In WebGrid.NET Enterprise 5.0 the new concept affects WebGrid’s mechanism for loading child tables on demand. Several important points for loading child tables on demand in version 5.0:

  • Load on demand data retrieval is no longer handled at WebGrid level.
  • The load on demand data retrieval is now handled at datasource level. At the time of WebGrid.NET Enterprise 5.0 release, the only datasource control type that support this operation is ISDataSource.

Configuring a WebGrid in v5.0 to display load on demand child table is now easier and simpler. There is no configuration needed to set at WebGrid level. At ISDataSource datasource control level, you can enable load on demand operation by simply setting LoadOnDemand property to True. Next, you provide the method that retrieve the child table data and assign it to the ISDataSource control.

<ISDataSource:ISDataSource ID="ISDataSource1" runat="server" LoadOnDemand="True" SchemaName="dsNorthwind">
...
</ISDataSource:ISDataSource>

 

In WebGrid.NET Enterprise 5.0 you do not need to write codes in the InitializeChildTableDataSource. There are two ways to provide the method for retrieving child table data:

  • Write codes for the method in App_Code.
    The following codes illustrate the technique to load Orders table when a Customer record is drilled down.

   public DataTable GetData(string customerID)

   {

     dsNorthwind.OrdersDataTable dt = new                 dsNorthwind.OrdersDataTable();  

 

     OleDbDataAdapter adapter = new OleDbDataAdapter();

  

     adapter.SelectCommand = new

     OleDbCommand("SELECT * FROM Orders WHERE CustomerID =  '"   + customerID + "'", this.Connection);

     adapter.Fill(dt);

 

   return dt;

   }

Using this technique, you can assign the ISDataSourceTable’s SelectMethod to GetData. 

  • Create the method in Visual Studio 2005’s DataSet Designer.
    Another way to create the data method is through DataSet Designer in Visual Studio 2005. The DataSet Designer enables you to create the method using a visual manner with less coding needed. For more information, please read Walkthrough: Loading child rows based on the selected parent row.

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.