This is a migrated thread and some comments may be shown as answers.

ClientEvents can't be captured on sorting on a <telerik:GridTemplateColumn> column

1 Answer 45 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Xavier
Top achievements
Rank 1
Xavier asked on 14 Sep 2014, 06:48 AM
Hi all, 
I am using radgrid to display some information. 
In my UI, I need to do some client side javascript checking when the user try to sort a column. 
In order to capture the sorting event, I add the following lines into the radgrid: 
<ClientSettings>
      <ClientEvents OnCommand="RaiseCommand"/>
</ClientSettings>
such that user command could be captured by the javascript function "RaiseCommand".
This works successfully with <telerik:GridBoundColumn>, but not with <telerik:GridTemplateColumn>.
When I do sorting on a <telerik:GridBoundColumn> column, the function "RaiseCommand" was triggered. 
However, when I do sorting on a <telerik:GridTemplateColumn> column, the function "RaiseCommand" wasn't triggered. 
For some reason, <telerik:GridTemplateColumn> need to be used in my grid.

As a illustration, here is my sample code:

Javascript:

        function RaiseCommand(sender, eventArgs) {
            var commandNameLowerCase = eventArgs.get_commandName().toLowerCase();
            if (commandNameLowerCase == "sort") {
                 //do some checking....
            }
        }

Here is aspx:
<telerik:RadGrid ID="radGridTesting" runat="server" AllowFilteringByColumn="True"
AllowPaging="true" AllowSorting="True" GridLines="None" ShowGroupPanel="True"
Skin="WebBlue" AutoGenerateColumns="False" EnableViewState="true"
PageSize="15">
    <GroupingSettings CaseSensitive="false" />
    <PagerStyle AlwaysVisible="true"/>
    <MasterTableView ClientDataKeyNames="TestID" EnableViewState="true" CommandItemDisplay="None" AllowPaging="true">
        <Columns>
            <telerik:GridBoundColumn UniqueName="StockCode" DataField="StockCode" AutoPostBackOnFilter="true" SortExpression="StockCode"     HeaderText="StockCode" ItemStyle-Wrap="false" />
        <telerik:GridTemplateColumn UniqueName="StockName" DataField="StockName" AutoPostBackOnFilter="true" SortExpression="StockName">
            <HeaderTemplate>
                <asp:linkbutton id="lnkStockName" runat="server" Text="StockName" CommandName="Sort" CommandArgument="StockName"/>
            </HeaderTemplate>
            <ItemTemplate>
                <asp:Label ID="lblStockName" runat="server" />
            </ItemTemplate>
        </telerik:GridTemplateColumn>
    </Columns>
    </MasterTableView>
    <ClientSettings>
        <ClientEvents OnCommand="RaiseCommand"/>
    </ClientSettings>
</telerik:RadGrid>

Could anyone advise me of what the problem is?
Any help will be greatly appreciated.

Regards,
Xavier

1 Answer, 1 is accepted

Sort by
0
Accepted
Eyup
Telerik team
answered on 17 Sep 2014, 06:48 AM
Hello Xavier,

Thank you for contacting us.

Remove the HeaderTemplate of the template column and set its header text to achieve the requested functionality:
<telerik:GridTemplateColumn ... HeaderText="StockName">

Hope this helps.

Regards,
Eyup
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Xavier
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or