New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

How to Fire Command Events

In some specific cases you may want to raise command events (like Edit/Update/Delete/Filter/Page/etc.) in code rather than clicking buttons/filter menu items in the grid. For such type of situations Telerik RadGrid exposes the FireCommandEvent(eventName, eventArgs) method which can be called for all items which extend the GridItem type (GridDataItem, GridFilteringItem, etc.).

The table below explains the parameters which you can pass to that method to fire corresponding commands:

 

GridCommandType of item used to invoke the methodFireCommandEvent syntaxeventArgs details
EditGridEditableItem, GridDataItemFireCommandEvent("Edit", GridCommandEventArgs)Required but not usedExample: FireCommandEvent("Edit", String.Empty)
UpdateGridEditableItem, GridDataItemFireCommandEvent("Update", GridCommandEventArgs)Required but not usedExample: FireCommandEvent("Update", String.Empty)
DeleteGridDataItemFireCommandEvent("Delete", GridCommandEventArgs)Required but not usedFireCommandEvent("Delete", String.Empty)
InitInsertGridEditableItem, GridCommandItemFireCommandEvent("InitInsert", GridCommandEventArgs)Required but not usedFireCommandEvent("InitInsert", String.Empty)
PerformInsertGridEditableItem,GridCommandItemFireCommandEvent("PerformInsert", GridCommandEventArgs)Required but not usedExample: FireCommandEvent("PerformInsert", String.Empty)
CancelGridEditableItemFireCommandEvent("Cancel", GridCommandEventArgs)Required but not usedExample: FireCommandEvent("Cancel", String.Empty)
PageGridPagerItemFireCommandEvent("Page", GridPageChangedEventArgs)string argument: "First", "Next", "Prev", "Last", numeric values as string presentationExample: FireCommandEvent("Page", "Next")
SortGridHeaderItemFireCommandEvent("Sort", GridSortCommandEventArgs)string argument: fieldName (mandatory), sortOrder (optional)Example: FireCommandEvent("Sort", "ContactName")
SelectGridDataItemFireCommandEvent("Select", GridSelectCommandEventArgs)Required but not usedExample: FireCommandEvent("Select", String.Empty)
DeselectGridDataItemFireCommandEvent("Deselect", GridDeselectCommandEventArgs)Required but not usedExample:FireCommandEvent("Deselect", String.Empty)
ExpandCollapseGridDataItemFireCommandEvent("ExpandCollapse", GridExpandCommandEventArgs)Required but not usedExample:FireCommandEvent("ExpandCollapse", String.Empty)
FilterGridFilteringItemFireCommandEvent("Filter", GridFilterCommandEventArgs)Pair holding the menu item value and the column UniqueNameExample: FireCommandEvent("Filter", new Pair(menuItem.Value,columnUniqueName))
HeaderContextMenuFilterGridHeaderItemFireCommandEvent("HeaderContextMenuFilter",GridHeaderContextMenuFilterEventArgs)Triplet holding the name of the column and two pairs for the filter conditions data.Example: FireCommandEvent("HeaderContextMenuFilter", new Triplet() { First = "OrderID", Second = new Pair() { First = "GreaterThan", Second = 10250 }, Third = new Pair() { First = "LessThan", Second = 10342 } } );
ExportToExcelGridCommandItemFireCommandEvent("ExportToExcel", GridCommandEventArgs)Required but not usedExample: FireCommandEvent("ExportToExcel", String.Empty)
ExportToWordGridCommandItemFireCommandEvent("ExportToWord", GridCommandEventArgs)Required but not usedExample: FireCommandEvent("ExportToWord", String.Empty)
ExportToPdfGridCommandItemFireCommandEvent("ExportToPdf", GridCommandEventArgs)Required but not usedExample: FireCommandEvent("ExportToPdf", String.Empty)
ExportToCsvGridCommandItemFireCommandEvent("ExportToCsv", GridCommandEventArgs)Required but not usedExample: FireCommandEvent("ExportToCsv", String.Empty)
EditSelectedGridCommandItemFireCommandEvent("EditSelected", GridCommandEventArgs)Required but not usedExample: FireCommandEvent("EditSelected", String.Empty)
UpdateEditedGridCommandItemFireCommandEvent("UpdateEdited", GridCommandEventArgs)Required but not usedExample: FireCommandEvent("UpdateEdited", String.Empty)
DeleteSelectedGridCommandItemFireCommandEvent("DeleteSelected", GridCommandEventArgs)Required but not usedExample: FireCommandEvent("DeleteSelected", String.Empty)
EditAllGridCommandItemFireCommandEvent("EditAll", GridCommandEventArgs)Required but not usedExample: FireCommandEvent("EditAll", String.Empty)
CancelAllGridCommandItemFireCommandEvent("CancelAll", GridCommandEventArgs)Required but not usedExample: FireCommandEvent("CancelAll", String.Empty)
DownloadAttachmentGridDataItemFireCommandEvent("DownloadAttachment", GridDownloadAttachmentCommandEventArgs)IDictionary collection of key/value pairs (see this demo )Example:Dictionary<string, object> dict = new Dictionary<string, object>();dict["ColumnUniqueName"] = "AttColumn1";dict["FileName"] = "report.doc";dict["FileId"] = "1423";FireCommandEvent("DownloadAttachment", dict)
Not finding the help you need?
Contact Support