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
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