First in the aspx or ascx page or controller,
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
function SortColumn(ColumnName)
{
var masterTable = $find("<%= Grid1.ClientID %>").get_masterTableView();
masterTable.sort(ColumnName);
}
</script>
</telerik:RadCodeBlock>
Then in the code behind, add the following code.
protected void Grid1_PreRender(object sender, EventArgse)
{
foreach (GridColumncol in Grid1.MasterTableView.RenderColumns)
{
foreach (GridHeaderItemheader in Grid1.MasterTableView.GetItems(GridItemType.Header))
{
header[col.UniqueName].Attributes.Add("OnClick", "return SortColumn('" + col.UniqueName + "');");
}
}
}
Hope this will help someone... Thanks :-)
No comments:
Post a Comment