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

GridViewToolbarItem.Command Property

Gets or sets the name of a command executed when clicking a toolbar item.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v18.2.dll

Declaration

[DefaultValue(GridViewToolbarCommand.Custom)]
public GridViewToolbarCommand Command { get; set; }
<DefaultValue(GridViewToolbarCommand.Custom)>
Public Property Command As GridViewToolbarCommand

Property Value

Type Default Description
GridViewToolbarCommand

Custom

One of the GridViewToolbarCommand enumeration values specifying the toolbar item's command name.

Remarks

Use the Command property to specify a command that will be executed when a toolbar item is clicked.

NOTE

The ASPxGridBase.KeyFieldName property should be specified when using the following grid features:

  • data editing;
  • adding new and deleting existing data item;
  • selecting data item;
  • master-detail view;
  • endless paging.

Concept

Example

WebForms:

NOTE

For a full example, see the ASPxGridView - Customization Dialog demo.


<dx:ASPxGridView ID="Grid" runat="server" DataSourceID="ProductsDataSource" EnableRowsCache="false" Width="100%">
    <Columns>
    ...
    </Columns>
    <SettingsCustomizationDialog Enabled="true" />
    <Toolbars>
        <dx:GridViewToolbar Position="Top" ItemAlign="Right">
            <Items>
                <dx:GridViewToolbarItem Command="ShowCustomizationDialog" />
            </Items>
        </dx:GridViewToolbar>
    </Toolbars>
</dx:ASPxGridView>

MVC:


@Html.DevExpress().GridView(
    settings =>
    {
        settings.Name = "grid";
        settings.KeyFieldName = "PersonID";
        settings.CallbackRouteValues = new { Controller = "Home", Action = "GridViewEditingPartial" };

        settings.SettingsEditing.AddNewRowRouteValues = new { Controller = "Home", Action = "EditingAddNew" };
        settings.SettingsEditing.UpdateRowRouteValues = new { Controller = "Home", Action = "EditingUpdate" };
        settings.SettingsEditing.DeleteRowRouteValues = new { Controller = "Home", Action = "EditingDelete" };
        settings.DeleteSelectedRowsRouteValues = new { Controller = "Home", Action = "EditingDeleteSelected" };

        settings.SettingsBehavior.AllowFocusedRow = true;
        settings.CommandColumn.Visible = true;
        settings.CommandColumn.ShowNewButton = true;
        settings.CommandColumn.ShowDeleteButton = true;
        settings.CommandColumn.ShowEditButton = true;
        settings.CommandColumn.ShowSelectCheckbox = true;
        settings.Toolbars.Add(toolbar =>
        {
            toolbar.Enabled = true;
            toolbar.Position = GridToolbarPosition.Top;
            toolbar.ItemAlign = GridToolbarItemAlign.Right;
            toolbar.Items.Add(GridViewToolbarCommand.New);
            toolbar.Items.Add(GridViewToolbarCommand.Edit);
            toolbar.Items.Add(GridViewToolbarCommand.Delete);
            toolbar.Items.Add(GridViewToolbarCommand.DeleteSelectedRowsOnPage);
            toolbar.Items.Add(GridViewToolbarCommand.Refresh, true);  
        });
        settings.Columns.Add("FirstName");
        settings.Columns.Add("MiddleName");
        settings.Columns.Add("LastName");
    }
).Bind(Model).GetHtml()
See Also