Skip to main content

Binding to Large Data (Database Server Mode)

  • 2 minutes to read

The ComboBoxExtension, TokenBoxExtension and ListBoxExtension extensions support database server mode. In this mode, list editors load only the required visible items into server memory and perform data-aware operations, such as filtering, at the database level.

To enable database server mode, bind list editors to a LinqServerModeDataSource or EntityServerModeDataSource data source with the BindToLINQ and BindToEF methods, and specify CallbackRouteValues. When a user applies a filter to a combo box or list box, the editor loads filtered data into server memory and displays it. You can also use the CustomFiltering property to implement custom filtering logic on the server side when the editor uses database server mode.

Tip

Refer to the Members Table for a list of the available APIs.

ASPxGridView_DataBinding_ServerMode

Partial View:

@Html.DevExpress().ComboBox(
    settings => {
        settings.Name = "comboBox";
        settings.Width = 285;
        settings.Properties.DropDownWidth = 350;
        settings.Properties.DropDownStyle = DropDownStyle.DropDown;
        settings.CallbackRouteValues = new { Controller = "Editors", Action = "LargeDataComboBoxPartial" };
        settings.Properties.CallbackPageSize = 15;
        settings.Properties.TextField = "FirstName";
        settings.Properties.FilterMinLength = 0;
        settings.Properties.TextFormatString = "{0} {1} {2}";
        settings.Properties.ValueField = "ID";
        settings.Properties.ValueType = typeof(int);

        settings.Properties.Columns.Add("FirstName", "FirstName", 90);
        settings.Properties.Columns.Add("LastName", "LastName", 90);
        settings.Properties.Columns.Add("Phone", "Phone", Unit.Percentage(100));

        settings.Properties.ClientSideEvents.BeginCallback = "OnStartCallback";
        settings.Properties.ClientSideEvents.EndCallback = "OnEndCallback";
    }
).BindToEF(string.Empty, string.Empty, (s, e) => {
    e.QueryableSource = LargeDatabaseDataProvider.DB.Persons;
}).GetHtml()

Online Demo

Refer to Large Database: Server Mode online demo to see this feature in action.

Member Table

The table below lists APIs that DevExpress List Editors use when working with large data sets in database server mode.

Class Binding members Filtering members
ComboBoxExtension ComboBoxExtension.BindToEF, ComboBoxExtension.BindToLINQ AutoCompleteBoxBaseSettings.CustomFiltering
TokenBoxExtension TokenBoxExtension.BindToEF, TokenBoxExtension.BindToLINQ AutoCompleteBoxBaseSettings.CustomFiltering
ListBoxExtension ListBoxExtension.BindToEF, ListBoxExtension.BindToLINQ ListBoxSettings.CustomFiltering

Database Server Mode Limitations

In database server mode, list editors transform filter expressions (Criteria language syntax) to SQL requests. If list editors (in multi-column mode) use the TextFormatString property, the filter expression ignores the “alignment” and “format string” format parameters.

The following table illustrates how the editor converts its format string in regular data binding mode and database server mode:

Regular Data Binding Database Server Mode
“{0:d} from {1,2:n}” “{0} from {1}”

Use the ListEditCustomFilteringEventArgs.FilterExpression property in the delegate specified by the CustomFiltering property to filter list editor items when format string functionality is applied. For a list of available APIs, see the Members Table.