Spread ASP.NET 17
Spread for ASP.NET 17 Product Documentation / Developer's Guide / Customizing User Interaction / Customizing Interaction with the Overall Component / Allowing Load on Demand
In This Topic
    Allowing Load on Demand
    In This Topic

    You can allow the Web page to load on demand -- as the user scrolls further down the spreadsheet the Spread component on the client loads another set of rows from the server as needed. The height of the component should be smaller than the height needed for the initial number of rows to load (LoadInitRowCount property); otherwise, the scroll bar will not be visible and you will need to use the next page icon instead of the scroll bar. The load on demand feature scrolls up to the maximum number of rows you have set with the page size. If the row count is greater than the page size, you will need to use the next page icon to display the rows beyond the page size setting.

    The following properties are used to set the allow load on demand feature. They can be set at the control level or the sheet level.

    FpSpread class:

    SheetView class:

    You can specify whether to use the standard or background load on demand options with the LoadOnDemandMode property.

    The load on demand feature is not intended to work with a hierarchical display (parent sheet expanding into child sheets) so it is disabled in a hierarchical Spread.

    Standard Load on Demand

    The standard mode only loads the next set of rows if there are rows that are hidden from the view. The default value for the LoadOnDemandMode property is standard.

    Background Load on Demand

    You can load new rows in the background before the last row is displayed. For example, if 20 rows are loaded and the user scrolls to row 15, the next set of rows is loaded. Set the LoadOnDemandMode property to Background to load the new rows before the last row is displayed. You can also specify whether to load the new rows using a time interval or when the scrolling is a specified number of rows from the bottom of the view. Use the LoadOnDemandTriggerMode property to specify whether to use a time interval or an offset from the bottom of the view.

    The background load on demand allows other pending AJAX requests while rows are being loaded (rows are loaded without locking the Spread). The actions are put in a queue of pending requests to be processed later. When load on demand is finished, pending requests in the queue are processed until there are no more requests in the queue.

    Virtual Paging

    Another option for loading pages as the user scrolls vertically is the AllowVirtualScrollPaging property. This can be used instead of the allow load on demand properties. The virtual paging feature will not work with load on demand. The EnableClientScript property must be true for the virtual paging. For the best performance, you may also wish to set EnableAjaxCall to true since the virtual paging uses Ajax calls.

    The virtual scrolling option scrolls from the first row to the last row of the page size. If the row count is greater than the page size, then when you scroll past the maximum page size row, the next set of rows is loaded (a wait icon is displayed while the next page is loading in this case).

    You can also display rows from the previous page with the VirtualScrollPagingPrevRowCount property.

    The scroll bar button size reflects the total number of rows with virtual scrolling (rather than the number of currently loaded rows).

    Using the Properties Window

    You can set several of the properties at design time using the Properties window of Visual Studio .NET or the Property grid in the designer.

    1. Select the sheet.
    2. Set the AllowLoadOnDemand property to true to allow loading on demand.
    3. Set the LoadInitRowCount property to specify the initial number of rows to load.
    4. Set the LoadRowIncrement property to specify how many rows to load after the initial set of rows is loaded.

    Using Code

    Use the AllowLoadOnDemand property to allow load on demand. Set the LoadInitRowCount property to load the initial set of rows. Set the LoadRowIncrement property to specify the number of rows to load after the initial page is loaded.

    Example

    The height of the component should be smaller than the height of ten rows (for this example).

    C#
    Copy Code
    FpSpread1.Sheets[0].RowCount = 40;
    FpSpread1.Sheets[0].AllowLoadOnDemand = True;
    FpSpread1.Sheets(0).PageSize = 40;
    FpSpread1.Sheets[0].LoadInitRowCount = 10;
    FpSpread1.Sheets[0].LoadRowIncrement = 10;
    long i;
    for (i = 1; i <= 20; i++)
    {
    FpSpread1.Sheets[0].Cells[i, 0].Value = i;
    }
    
    VB
    Copy Code
    FpSpread1.Sheets(0).RowCount = 40
    FpSpread1.Sheets(0).AllowLoadOnDemand = True
    FpSpread1.Sheets(0).PageSize = 40
    FpSpread1.Sheets(0).LoadInitRowCount = 10
    FpSpread1.Sheets(0).LoadRowIncrement = 10
    Dim i As Long
    For i = 1 To 20
    FpSpread1.Sheets(0).Cells(i, 0).Value = i
    Next
    
    See Also