A newer version of this page is available. Switch to the current version.

Binding to Large Data (Database Server Mode)

  • 2 minutes to read

The ComboBoxExtension, TokenBoxExtension and ListBoxExtension extensions support the database server mode. In this mode, list editors load only the required (visible) items to the server memory and implement data-aware operations (for example, filtering) at database level.

To enable database server mode, bind list editors to a LinqServerModeDataSource or EntityServerModeDataSource data source (BindToLINQ and BindToEF methods) and use the CallbackRouteValues method. When a user applies a filter to a combo box or list box, the editor loads the filtered data to the server memory and displays this data. You can also use the CustomFiltering property to specify a delegate function to implement custom filtering logic on the server side (when the editor operates in 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 with the delegate the CustomFiltering property specifies to filter list editors items when the format string functionality is applied. Refer to the Members Table for a list of the available APIs.