Skip to main content

How to: Create an Item Template

  • 2 minutes to read

This example illustrates how to modify the layout of editor list items. To create a template for them, use the GridViewProperties.Templates.DataRow property (GridViewTemplates.DataRow).

Note that the incremental filtering functionality (enabled by the ASPxGridLookup.IncrementalFilteringMode property) works correctly when the list item template feature is used.

In this demo, incremental filtering is based on the values of the first two data columns defined within the editor’s ASPxGridLookup.Columns collection - ‘First Name’ and ‘Last Name’. These columns are specified in the ASPxGridLookup.TextFormatString property as indexed placeholders ({0} and {1}) that correspond to column indexes within the ASPxGridLookup.Columns collection.
Thus, the ASPxGridLookup.TextFormatString property defines the format to display the selected item’s value within the edit box (‘First Name’ ‘Last Name’) and determines the search format for the filter string (columns and valid literals).

gridlookup-templates.png

    protected void Page_Load(object sender, EventArgs e) {
        GridLookup.GridView.Width = 300;
        GridLookup.GridView.DataBound += grdSelectFilters_SelectFilters_DataBound;
        UpdateGridViewHeigth();
    }
    protected void grdSelectFilters_SelectFilters_DataBound(object sender, EventArgs e) {
        UpdateGridViewHeigth();
    }
    protected void UpdateGridViewHeigth() {
        if (GridLookup.GridView.VisibleRowCount > 2) {
            GridLookup.GridView.Settings.ShowVerticalScrollBar = true;
            GridLookup.GridView.Settings.VerticalScrollableHeight = 300;
        }
        else 
            GridLookup.GridView.Settings.ShowVerticalScrollBar = false;
    }