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

Sorting problem when apply grouping

3 Answers 88 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kiran
Top achievements
Rank 1
Kiran asked on 04 Nov 2010, 09:30 PM
Dear there,

I am using radgrid control, everything was working well before  i applied grouping, but afterthere sorting is not working.  

here is my grid, my grid is simpy binding on pageload event. Do i need to write manual sortcommand on server side ?

<telerik:RadGrid ID="RadGrid1" AllowSorting="true" Width="100%"   runat="server" >
              
            <MasterTableView  TableLayout="Fixed" DataKeyNames="KEYID" ClientDataKeyNames="KEYID" GridLines="Both" 
             GroupsDefaultExpanded="true"  
             GroupLoadMode="client"   >
              
             <GroupByExpressions>
              
                    <telerik:GridGroupByExpression>
                      
                        <SelectFields >
                            <telerik:GridGroupByField SortOrder="Ascending"   FieldAlias="EMPDOH" FieldName="EMPDOH" FormatString="{0:D}" HeaderValueSeparator=" from date: "></telerik:GridGroupByField>
                        </SelectFields>
                        <GroupByFields>
                            <telerik:GridGroupByField FieldName="EMPDOH" SortOrder="Ascending"></telerik:GridGroupByField>
                        </GroupByFields>
                    </telerik:GridGroupByExpression >
                     
                </GroupByExpressions>
  
                <Columns>
                    <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn" />
                    <telerik:GridBoundColumn UniqueName="KEYID" Display="false" DataField="KEYID">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn HeaderText="Employees" DataField="Name" UniqueName="Name"
                        ShowFilterIcon="false" SortExpression="Name" AllowFiltering="true" FilterControlWidth="100"
                        AutoPostBackOnFilter="true" />
                    <telerik:GridBoundColumn HeaderText="Pay Period" DataField="Description" UniqueName="Description"
                        ShowFilterIcon="false" SortExpression="Description">
                        <FilterTemplate>
                            <telerik:RadComboBox ID="RadComboBoxPP" CausesValidation="false" Width="100" DataSourceID="SqlDataSourcePP"
                                DataTextField="Code" DataValueField="Code" Height="100px" AppendDataBoundItems="true"
                                OnClientSelectedIndexChanged="SelectedIndexChanged" SelectedValue='<%# TryCast(Container, GridItem).OwnerTableView.GetColumn("Description").CurrentFilterValue %>'
                                runat="server">
                                <Items>
                                    <telerik:RadComboBoxItem Text="All" />
                                </Items>
                            </telerik:RadComboBox>
                            <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
  
                                <script type="text/javascript">
                                    function SelectedIndexChanged(sender, args) {
                                        var tableView = $find("<%# TryCast(Container, GridItem).OwnerTableView.ClientID %>");
                                        sender.value = args.get_item().get_value();
                                        tableView.filter("Description", args.get_item().get_value(), "EqualTo");
                                    }
                                </script>
  
                            </telerik:RadScriptBlock>
                        </FilterTemplate>
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn HeaderText="Department" DataField="Department" UniqueName="Department"
                        ShowFilterIcon="false" SortExpression="Department">
                        <FilterTemplate>
                            <telerik:RadComboBox ID="RadComboBoxDep" CausesValidation="false" DataSourceID="SqlDataSourceDepartment"
                                Width="120" DataTextField="Department" DataValueField="Department" Height="100px"
                                AppendDataBoundItems="true" OnClientSelectedIndexChanged="SelectedIndexChanged2"
                                SelectedValue='<%# TryCast(Container, GridItem).OwnerTableView.GetColumn("Department").CurrentFilterValue %>'
                                runat="server">
                                <Items>
                                    <telerik:RadComboBoxItem Text="All" />
                                </Items>
                            </telerik:RadComboBox>
                            <telerik:RadScriptBlock ID="RadScriptBlock2" runat="server">
  
                                <script type="text/javascript">
                                    function SelectedIndexChanged2(sender, args) {
                                        var tableView = $find("<%# TryCast(Container, GridItem).OwnerTableView.ClientID %>");
                                        sender.value = args.get_item().get_value();
                                        tableView.filter("Department", args.get_item().get_value(), "EqualTo");
                                    }
                                </script>
  
                            </telerik:RadScriptBlock>
                        </FilterTemplate>
                    </telerik:GridBoundColumn>
                    <telerik:GridDateTimeColumn ReadOnly="true" DataField="Paydate" HeaderText="Pay Date"
                        DataFormatString="{0:d}" DataType="System.DateTime" UniqueName="PayDate" AllowFiltering="true"
                        SortExpression="PayDate" FilterControlWidth="90" />
                    <telerik:GridBoundColumn AllowFiltering="false" HeaderText="Start Date" DataFormatString="{0:d}"
                        DataField="PayDateFrom" UniqueName="PayDateFrom" DataType="System.DateTime" ShowFilterIcon="false"
                        SortExpression="PayDateFrom" />
                    <telerik:GridBoundColumn HeaderText="End Date" DataField="Paydateto" DataFormatString="{0:d}"
                        UniqueName="Paydateto" DataType="System.DateTime" ShowFilterIcon="false" AllowFiltering="false"
                        SortExpression="Paydateto" />
                    <telerik:GridBoundColumn HeaderText="Hire/Rehire" DataField="EMPDOH" Groupable="true" UniqueName="EMPDOH"
                        DataFormatString="{0:d}" DataType="System.DateTime" ShowFilterIcon="false" AllowFiltering="false"
                        SortExpression="EMPDOH" />
                    <telerik:GridBoundColumn DataField="hdismass" UniqueName="hdismass" Display="false"
                        HeaderText="hdismass" AllowFiltering="false" />
                    <telerik:GridBoundColumn HeaderText="hds" DataField="hds" Display="false" UniqueName="hds"
                        AllowFiltering="false" />
                </Columns>
            </MasterTableView>
            <ClientSettings AllowColumnsReorder="false" ReorderColumnsOnClient="false" AllowExpandCollapse="true"  >
                <Selecting AllowRowSelect="true" />
                <Resizing AllowRowResize="false" EnableRealTimeResize="True" ResizeGridOnColumnResize="true"
                    AllowColumnResize="false"></Resizing>
            </ClientSettings>
             <GroupingSettings ShowUnGroupButton="true" />
  
        </telerik:RadGrid>

3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 05 Nov 2010, 11:14 AM
Hello Kiran,

When you want the grid to perform complex operations like paging,sorting and grouping, it is better to use Advanced DataBinding(using NeedDataSource event) rather than Simple DataBinding. Try to populate grid using Advanced DataBinding and see whether this avoids the issue.

The following Demo shows how to populate grid using Advanced DataBinding
Grid / Advanced Data Binding


Thanks,
Princy.
0
Kiran
Top achievements
Rank 1
answered on 05 Nov 2010, 02:59 PM
Thanks for your quick response,

Actually sorting was working. somehow i got confused because of in the grid. each grouping was having only 1 record. thats why it doesnt make any diffrence in the sorting. but now it fixed

I have one more question about checkboxes, as you can see i am using GridClientSelectColumn
 to select the rows, is this chekboxes are reason to perform slow. once grid loaded in codebehind, it seems still in processing to executing javascript. what should i do to avoid this ? i have a grid with around 200 records, when i click header checkbox to select all records it takes around 10 seconds, which is really irritating for users. please suggest on this.

HTML Grid code as it is in my previous post

 

 

0
Pavlina
Telerik team
answered on 05 Nov 2010, 06:41 PM
Hi Kiran,

Please refer to the forum post below which elaborates on this matter and see if it helps:
http://www.telerik.com/community/forums/aspnet/grid/slowness-of-the-quot-select-unselect-all-quot-check-box-operation-in-radgrid.aspx

Regards,
Pavlina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Grid
Asked by
Kiran
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Kiran
Top achievements
Rank 1
Pavlina
Telerik team
Share this question
or