Intersoft WebGrid Documentation
LoadOnDemand Property
See Also  Example Send Feedback
ISNet.WebUI.WebGrid Namespace > SelfReferencingSettings Class : LoadOnDemand Property






Specifies whether to enable the LoadOnDemand feature. If this is enabled, the grid must have the InitializeSelfReferenceDataSource event handler implemented.

Syntax

Visual Basic (Declaration) 
<ISNet.Serialization.BinarySerializableAttribute()>
<ISNet.Serialization.XmlSerializableAttribute()>
<DefaultValueAttribute()>
<NotifyParentPropertyAttribute(True)>
<DescriptionAttribute("Determines whether the child rows should be loaded on demand, instead of loaded at once in first request.")>
Public Property LoadOnDemand As Boolean
Visual Basic (Usage)Copy Code
Dim instance As SelfReferencingSettings
Dim value As Boolean
 
instance.LoadOnDemand = value
 
value = instance.LoadOnDemand
C# 
[ISNet.Serialization.BinarySerializableAttribute()]
[ISNet.Serialization.XmlSerializableAttribute()]
[DefaultValueAttribute()]
[NotifyParentPropertyAttribute(true)]
[DescriptionAttribute("Determines whether the child rows should be loaded on demand, instead of loaded at once in first request.")]
public bool LoadOnDemand {get; set;}
Delphi 
public read-write property LoadOnDemand: Boolean; 
JScript 
ISNet.Serialization.BinarySerializableAttribute()
ISNet.Serialization.XmlSerializableAttribute()
DefaultValueAttribute()
NotifyParentPropertyAttribute()
DescriptionAttribute("Determines whether the child rows should be loaded on demand, instead of loaded at once in first request.")
public function get,set LoadOnDemand : boolean
Managed Extensions for C++ 
[ISNet.Serialization.BinarySerializableAttribute()]
[ISNet.Serialization.XmlSerializableAttribute()]
[DefaultValueAttribute()]
[NotifyParentPropertyAttribute(true)]
[DescriptionAttribute("Determines whether the child rows should be loaded on demand, instead of loaded at once in first request.")]
public: __property bool get_LoadOnDemand();
public: __property void set_LoadOnDemand( 
   bool value
);
C++/CLI 
[ISNet.Serialization.BinarySerializableAttribute()]
[ISNet.Serialization.XmlSerializableAttribute()]
[DefaultValueAttribute()]
[NotifyParentPropertyAttribute(true)]
[DescriptionAttribute("Determines whether the child rows should be loaded on demand, instead of loaded at once in first request.")]
public:
property bool LoadOnDemand {
   bool get();
   void set (    bool value);
}

Example


The following is the sample code for the InitializeSelfReferenceDataSource event
C#Copy Code
private void WebGrid1_InitializeSelfReferenceDataSource(object sender,
ISNet.WebUI.WebGrid.ChildTableDataSourceEventArgs e)
{
    DataTable dt = (DataTable)e.DataSource;
    oleDbDataAdapter1.SelectCommand.CommandText =
        "select * from employees where ReportsTo = " +
        e.ParentKeyValues["EmployeeID"].ToString();
        
    oleDbDataAdapter1.SelectCommand.CommandType = CommandType.Text;
    oleDbDataAdapter1.Fill(dt);
}
The following is the sample code for the InitializeDataSource event.
C#Copy Code
private void WebGrid1_InitializeDataSource(object sender,
ISNet.WebUI.WebGrid.DataSourceEventArgs e)
{
    oleDbDataAdapter1.SelectCommand.CommandText =
        "select * from employees where ReportsTo is null";
    oleDbDataAdapter1.SelectCommand.CommandType = CommandType.Text;
    oleDbDataAdapter1.Fill(dsNorthWindEnt1.Employees);
    e.DataSource = dsNorthWindEnt1;
}

Remarks

Load on demand feature enables you to retrieve the child rows when the specific parent node is clicked. This flexible feature allows larger data table to be retrieved efficiently. When working in load on demand mode, the first time the page load it will only populate the parent rows and hence you only need to supply the parent rows datasource. Afterward, you need to implement InitializeSelfReferenceDataSource server event to handle the process of retrieving childrows' datasource. In the event, you only need to fill the childrows into the datatable like in the sample below, the grid will be able to automatically populate the childrows without additional codes.

Since Hierarchical and SelfReferencing can be both enabled at the same time, load on demand for both features can also be enabled in such advanced scenarios. Simply handle InitializeChildTableDataSource for Hierarchical mode and InitializeSelfReferenceDataSource for SelfReferencing mode (Please look at the sample codes above).

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

Reference

SelfReferencingSettings Class
SelfReferencingSettings Members

Tasks

Walkthrough: Creating Self Reference LoadOnDemand WebGrid
How-to: Remove (+) sign for Self Reference LoadOnDemand rows that contain no Child Row

Concepts

Self Referencing Table
Creating Self Reference Table

Other Resources

Hierarchical Self Reference

©2012 Intersoft Solutions Corp. All Rights Reserved.