<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
>
<
MasterTableView
>
<
Columns
>
<
telerik:GridClientDeleteColumn
CommandName
=
"Delete"
ButtonType
=
"LinkButton"
></
telerik:GridClientDeleteColumn
>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
>
<
ClientEvents
OnCommand
=
"OnCommand"
/>
</
ClientSettings
>
</
telerik:RadGrid
>
function
OnCommand(sender, args) {
}
Thank you for your time in reporting this problem.
I would like to share two approaches that can serve as a viable workaround:
Markup declaration:
<telerik:GridClientDeleteColumn UniqueName="MyDeleteColumn" CommandName="Delete" ButtonType="ImageButton"></telerik:GridClientDeleteColumn>
JavaScript - OnCommand event handler:function OnCommand(sender, args) {
if (args.get_commandName() == "Delete") {
args.set_cancel(true);
}
}
2. Use a Template Column with a RadButton that executes a JavaScript method on click.
Markup declaration
<telerik:GridTemplateColumn>
<ItemTemplate>
<telerik:RadButton ID="RadButton1" runat="server" Text="Delete" AutoPostBack="false" OnClientClicked="OnClientClicked"/>
</ItemTemplate>
</telerik:GridTemplateColumn>
JavaScript - OnClientCliecked event handler:
function OnClientClicked(sender, args) {
let buttonElement = sender.get_element();
let gridElement = $(buttonElement).closest('.RadGrid')[0];
if (gridElement && gridElement.control) {
let grid = gridElement.control;
let masterTable = grid.get_masterTableView();
masterTable.get_dataItems();
let rowElement = $(buttonElement).closest('tr')[0];
if (rowElement && rowElement.control) {
let dataItem = rowElement.control;
let itemIndex = dataItem.get_itemIndex();
masterTable._deleteRow(rowElement, itemIndex);
}
}
}
Kind regards,
Doncho
Progress Telerik