The requested page is not available for the requested platform. You are viewing the content for Default platform.

GridControl.IsLoadMoreEnabled Property

Gets or sets whether the load-more functionality is enabled in the grid. This is a bindable property.

Namespace: DevExpress.Mobile.DataGrid

Assembly: DevExpress.Mobile.Grid.v18.2.dll

Declaration

[XtraSerializableProperty]
public bool IsLoadMoreEnabled { get; set; }
<XtraSerializableProperty>
Public Property IsLoadMoreEnabled As Boolean

Property Value

Type Description
Boolean

true, to enable the load-more feature; otherwise, false.

Remarks

Important

This documentation topic describes legacy technology. We no longer develop new functionality for the GridControl and suggest that you use the new DataGridView control instead.

The GridControl supports dynamic loading of new data records from the bound data source when an end-user scrolls to the bottom of the grid. To enable this functionality, set the IsLoadMoreEnabled property to true. Then, either define a command in a view model and bind it to the grid using the GridControl.LoadMoreCommand property, or handle the GridControl.LoadMore event.

Examples

This example shows how to implement the grid's load-more feature - when an end-user scrolls to the bottom of the grid, a set of new data items is added to the end of the grid. To add this functionality, follow the steps below.

  1. Set the GridControl.IsLoadMoreEnabled property to true to enable the grid's load-more feature.
  2. Create a command to be executed when an end-user scrolls to the bottom of the grid.
  3. Bind the created command to the grid using the GridControl.LoadMoreCommand property.

In this example, data items for each next load (ten new orders) are generated randomly in code. The maximum number of loads an end-user is allowed to perform is 10. The count of data items currently loaded to the grid is displayed by the total summary that is automatically updated after each load.

GridControl_LoadMore

public partial class MainPage : ContentPage
{
    OrdersRepository repository;
    public static readonly BindableProperty LoadMoreCommandProperty = BindableProperty.Create<MainPage, LoadMoreDataCommand>(o => o.LoadMoreCommand, null);
    public static readonly BindableProperty OrdersProperty = BindableProperty.Create<MainPage, ObservableCollection<Order>>(o => o.Orders, null);

    public LoadMoreDataCommand LoadMoreCommand {
        get { return (LoadMoreDataCommand)GetValue(LoadMoreCommandProperty); }
        set { SetValue(LoadMoreCommandProperty, value); }
    }

    public ObservableCollection<Order> Orders {
        get { return (ObservableCollection<Order>)GetValue(OrdersProperty); }
        set { SetValue(OrdersProperty, value); }
    }

    public MainPage () {
        InitializeComponent ();

        BindingContext = this;
        this.repository = new TestOrdersRepository();
        this.Orders = repository.Orders;
        LoadMoreCommand = new LoadMoreDataCommand(ExecuteLoadMoreCommand);
    }

    void ExecuteLoadMoreCommand() {
        repository.LoadMoreOrders();
        Orders = repository.Orders;
    }
}

public class LoadMoreDataCommand : ICommand {
    readonly Action execute;

    int numOfLoadMore;
    public event EventHandler CanExecuteChanged;

    public LoadMoreDataCommand(Action execute) {
        this.execute = execute;
    }

    public bool CanExecute(object parameter) {
        if (numOfLoadMore < 10) {
            return true;
        }
        return false;
    }

    public void Execute(object parameter) {
        numOfLoadMore++;
        this.execute();
    }
}
<dxGrid:GridControl ItemsSource="{Binding Orders}" 
                    LoadMoreCommand="{Binding LoadMoreCommand}" IsLoadMoreEnabled="True">
See Also