GridButtonColumn
It displays a button for each item in the column.
This column renderes a button of the specified ButtonType in each corresponding cell of the items of type GridDataItem and GridEditFormItem. You can use this buttons to fire command events that can be handeled in ItemCommand event handler. This, in combination with the event bubbling mechanism in Telerik RadGrid, allows you to create a column of custom button controls, such as Add, Remove, Select or Edit buttons.
The available buttons types are: PushButton,LinkButton and ImageButton. Telerik RadGrid comes with two types of button columns:
- Select - when a button in this column is pressed, it will select the whole row. The Select column below uses a PushButton.
- Remove selection - when a button in this column is pressed, it will delete the row. The Remove selection column below uses a LinkButton.
Definition
Namespace:Telerik.Web.UI
Assembly:Telerik.Web.UI.dll
Syntax:
public class GridButtonColumn : GridColumn, IStateManager, IComparable
Inheritance: objectGridColumnGridButtonColumn
Derived Classes:
Implements:
Inherited Members
Example:
<radG:GridButtonColumn FooterText="PushButtonColumn<br/>footer" DataTextFormatString="Select {0}"
ButtonType="PushButton" UniqueName="column" HeaderText="PushButton<br/>Column"
CommandName="Select" DataTextField="CustomerID">
</radG:GridButtonColumn>
Constructors
Constructs a new GridButtonColumn object.
public GridButtonColumn()
Properties
Gets or sets the CssClass of the button
public virtual string ButtonCssClass { get; set; }
Gets or sets a value indicating the type of the button that will be rendered. The type should be one of the specified by the GridButtonColumnType enumeration.
public virtual GridButtonColumnType ButtonType { get; set; }
LinkButton Renders a standard hyperlink button. PushButton Renders a standard button. ImageButton Renders an image that acts like a button.
Gets or sets an optional parameter passed to the Command event along with the associated CommandName.
public virtual string CommandArgument { get; set; }
Gets or sets a value defining the name of the command that will be fired when a button in this column is clicked.
public virtual string CommandName { get; set; }
Fired By controls within DataItems - showing and editing data
CancelCommandName Represents the Cancel command name. Fires RadGrid.CancelCommand event and sets Item.Edit to false for the parent Item. DeleteCommandName Represents the Delete command name. Fires RadGrid.DeleteCommand event. Under .Net 2.0 performs automatic delete operation and then sets Item.Edit to false. UpdateCommandName Represents the Update command name. Fires RadGrid.UpdateCommand event. Under .Net 2.0 performs automatic update operation and then sets Item.Edit to false. EditCommandName
Represents the Edit command name. Sets Item.Edit to true. SelectCommandName
Represents the Select command name. Sets Item.Selected to true. DeselectCommandName
Represents the Deselect command name. Sets Item.Selected to false. Can be fired by controls within any Item
InitInsertCommandName
By default grid renders an image button in the CommandItem. Opens the insert item. PerformInsertCommandName
Fires RadGrid.InsertCommand event. Under .Net 2.0 Perfoms automatic insert operation and closes the insert item. RebindGridCommandName
By default grid renders an image button in the CommandItem. Forces RadGrid.Rebind SortCommandName
Represents the Sort command name. By default it is fired by image buttons in the header item when Sorting is enabled. The argument for the SortCommand must be the DataField name for the DataField to be sorted.
Gets or sets the height of the Confirm Dialog (if it is a RadWindow)
public virtual Unit ConfirmDialogHeight { get; set; }
Gets or sets what kind of confirm dialog will be used in a GridButtonColumn.
public virtual GridConfirmDialogType ConfirmDialogType { get; set; }
The type of the confirm dialog.
Gets or sets the width of the Confirm Dialog (if it is a RadWindow)
public virtual Unit ConfirmDialogWidth { get; set; }
Gets or sets the text that will be shown on the confirmation dialog when a button in this column is clicked. The prompt is automatically enabled when this property is set.
public virtual string ConfirmText { get; set; }
Gets or sets a string, representing a comma-separated enumeration of DataFields from the data source, which will be applied to the formatting specified in the ConfirmTextFormatString property.
[SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays")]
[TypeConverter(typeof(GridStringArrayConverter))]
public virtual string[] ConfirmTextFields { get; set; }
A string, representing a comma-separated enumeration of DataFields from the data source, which will be applied to the formatting specified in the ConfirmTextFormatString property.
Gets or sets a string, specifying the FormatString of the ConfirmText.
public virtual string ConfirmTextFormatString { get; set; }
A string, specifying the FormatString of the ConfirmText.
Gets or sets the title that will be shown on the RadWindow confirmation dialog when a button in this column is clicked.
public virtual string ConfirmTitle { get; set; }
Gets or sets a value from the specified datasource field. This value will then be displayed in the GridBoundColumn.
public virtual string DataTextField { get; set; }
Use the DataTextField property to specify the field name from the data source to bind to the Text property of the buttons in the GridButtonColumn object. Binding the column to a field instead of directly setting the Text property allows you to display different captions for the buttons in the GridButtonColumn by using the values in the specified field.
Tip: This property is most often used in combination with DataTextFormatString Property.
Gets or sets the string that specifies the display format for the caption in each button.
public virtual string DataTextFormatString { get; set; }
Use the DataTextFormatString property to provide a custom display format for the caption of the buttons in the GridButtonColumn.
Note: The entire string must be enclosed in braces to indicate that it is a format string and not a literal string. Any text outside the braces is displayed as literal text.
Gets or sets a value indicating the URL for the image that will be used in a Image button. ButtonType should be set to ImageButton.
public virtual string ImageUrl { get; set; }
Gets the status of ShowInEditForm property.
public override bool IsEditable { get; }
Overrides:
Gets the value determining if the column is selectable.
public override bool Selectable { get; }
The value determining if the column is selectable.
Overrides:
If the corresponding GridTableView is in edit mode InPlace specifies whether this column will render an Enabled=true button control, when the corresponding item is edit mode.
public virtual bool ShowInEditForm { get; set; }
Methods
Returns a copy of the GridButtonColumn.
protected override void CopyBaseProperties(GridColumn FromColumn)
Overrides:
The Initialize method is inherited by a derived GridButtonColumn class. Is is used to reset a column of the derived type.
public override void Initialize()
Overrides:
After a call to this method the column should add the corresponding button into the cell given, regarding the inItem type and column index.
Note: This method is called within RadGrid and is not intended to be used directly from your code.
[SuppressMessage("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
protected virtual void SetConfirmMessage(WebControl control)