Skip to content

Latest commit

 

History

History
71 lines (59 loc) · 2.54 KB

grid-disable-postback-on-row-click-for-specific-columns.md

File metadata and controls

71 lines (59 loc) · 2.54 KB
title description type page_title slug res_type ticket-id
Disable postback on row click for specific columns
Learn how to disable postback on row click for specific columns
how-to
Disable postback on row click for specific columns. | RadGrid
grid-disable-postback-on-row-click-for-specific-columns
kb
1645757

Environment

Product Telerik WebForms Grid for ASP.NET AJAX

DESCRIPTION

Sometimes, you might want to disable the EnablePostBackOnRowClick property when clicking on a cell, which is located in a specific column.

Disable EnablePostBackOnRowClick for specific columns

SOLUTION

To do that, you can utilize the [OnCellSelecting]({%slug grid/client-side-programming/events/oncellselecting%}) event, and in it, check for the unique name of the column of the currently clicked cell.

function onCellSelecting(sender, args) {
    var columnName = args.get_column().get_uniqueName();

    if (columnName == "OrderID") { 
        sender.ClientSettings.EnablePostBackOnRowClick = false;
        args.set_cancel(true);
    }
    else {
        sender.ClientSettings.EnablePostBackOnRowClick = true;
    }
}
<telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="True" Width="400px" OnNeedDataSource="RadGrid1_NeedDataSource">
    <MasterTableView AutoGenerateColumns="False" DataKeyNames="OrderID">
        <Columns>
            <telerik:GridBoundColumn DataField="OrderID" DataType="System.Int32"
                FilterControlAltText="Filter OrderID column" HeaderText="OrderID"
                ReadOnly="True" SortExpression="OrderID" UniqueName="OrderID">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="ShipName"
                FilterControlAltText="Filter ShipName column" HeaderText="ShipName"
                SortExpression="ShipName" UniqueName="ShipName">
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="ShipCountry"
                FilterControlAltText="Filter ShipCountry column" HeaderText="ShipCountry"
                SortExpression="ShipCountry" UniqueName="ShipCountry">
            </telerik:GridBoundColumn>
        </Columns>
    </MasterTableView>
    <ClientSettings EnablePostBackOnRowClick="true">
        <Selecting CellSelectionMode="SingleCell"/>
        <ClientEvents OnCellSelecting="onCellSelecting" />
    </ClientSettings>
</telerik:RadGrid>