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

[Solved] Custom Sorting Issue

1 Answer 122 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mahesh Babu
Top achievements
Rank 1
Mahesh Babu asked on 03 Jul 2009, 11:56 AM
Hi,

I want to do custom sorting for which I declared my RadGrid in aspx page  as given below:

<telerik:RadGrid AutoGenerateColumns="False" ID="RadGrid1" DataSourceID="SqlDS" AllowFilteringByColumn="true"
            AllowPaging="True" AllowSorting="True" runat="server" Skin="Office2007" OnPageIndexChanged="RadGrid1_PageIndexChanged"
            OnPageSizeChanged="RadGrid1_PageSizeChanged" OnSortCommand="RadGrid_SortCommand">
            <PagerStyle Mode="NextPrevNumericAndAdvanced" />
            <MasterTableView AllowCustomPaging="true" AllowCustomSorting="true">
                <PagerStyle Mode="NextPrevNumericAndAdvanced" />
                <Columns>
                    <telerik:GridBoundColumn SortExpression="RollNo" HeaderButtonType="TextButton"
                        ShowSortIcon="true">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn SortExpression="StudentName" HeaderButtonType="TextButton" ShowSortIcon="true">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn SortExpression="Address" HeaderButtonType="TextButton" ShowSortIcon="true">
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
    </telerik:RadGrid>
<asp:SqlDataSource ID="SqlDS" runat="server" ConnectionString="<%$connectionStrings:cemiConnectionString1%>">
</asp:SqlDataSource>

I want to generate GridBoundColumn's at runtime only as I know which columns I need to show at runtime only. so, I removed the three grid bound columns(RollNo,StudentName and Addresss) from design page. When I remove these columns and adding at runtime, postback is not calling onSortCommand event handler(RadGrid_SortCommand). If I add only RollNo gridboundcolumn then postback is calling my sort event handler for only RollNo column, for others(StudentName,Address) it not calling.

Could you please let me know what is the issue???


Thanks,
Mahesh

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 06 Jul 2009, 07:57 AM
Hi Mahesh,

I am not sure what is happening on your end. SortCommand must be firing for both dynamically added as well as statically declared columns.  But while adding a column dynamically to a statically declared Grid you must take care of one thing : Add the column to the column collection first and then set its properties.

Shinu.
Tags
Grid
Asked by
Mahesh Babu
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or