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

RadGrid Sorting doesn't work.

5 Answers 651 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Huxu
Top achievements
Rank 1
Huxu asked on 05 Jan 2015, 11:02 PM
I have problem get sorting working. Code is below:

    <telerik:RadGrid ID="RadGridList" runat="server" AutoGenerateColumns="false" AllowSorting="true" AllowPaging="true" PageSize="20" ShowGroupPanel="true" AllowFilteringByColumn="true">
        <GroupingSettings ShowUnGroupButton="true" />
        <MasterTableView GroupLoadMode="Client" TableLayout="Fixed" EnableGroupsExpandAll="true" AllowCustomSorting="true">
            <GroupByExpressions>
                <telerik:GridGroupByExpression>
                    <SelectFields>
                        <telerik:GridGroupByField FieldAlias="Name" FieldName="Name" />
                    </SelectFields>
                    <GroupByFields>
                        <telerik:GridGroupByField FieldName="Name" SortOrder="Descending" />
                    </GroupByFields>
                </telerik:GridGroupByExpression>
            </GroupByExpressions>
            <Columns>
                <telerik:GridBoundColumn DataField="Name" HeaderText="Name" AllowSorting="true"></telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Id" HeaderText="ID"></telerik:GridBoundColumn>
            </Columns>
        </MasterTableView>
        <GroupingSettings ShowUnGroupButton="true" />
        <ClientSettings AllowDragToGroup="true">
            <Selecting AllowRowSelect="true" />
        </ClientSettings>
    </telerik:RadGrid>

Sorting in GroupByExpression tag does work. The column sorting doesn't work. Any idea is appreciated!











5 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 08 Jan 2015, 08:35 PM
Hi,

Could you confirm that you have populate the grid using NeedDataSource event as shown in this demo:
http://demos.telerik.com/aspnet-ajax/grid/examples/data-binding/simple-vs-advanced/defaultcs.aspx


Also check the developer console of your browser and make sure that you have not receive a JavaScript error when you click on a column header. 

Regards,
Pavlina
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.

 
0
Shafqat
Top achievements
Rank 1
answered on 28 Dec 2016, 02:49 PM

Hi Pavlina

i have aslo sorting issue with Telerik RadGrid. I am using autogenerated columns, some of columns are sorting but in same grid some of columns are not sorting.

Thank you

0
Konstantin Dikov
Telerik team
answered on 28 Dec 2016, 03:23 PM
Hi Shafqat,

The columns will be sorted based on the underlying data type. If you are referring to the problems with the dates mentioned in the other forum thread where you have posted, please try the workaround that you have used previously, where you are casting the string to date.


Best Regards,
Konstantin Dikov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Shafqat
Top achievements
Rank 1
answered on 28 Dec 2016, 05:37 PM

Hi Konstantin Dikov
Thank you for reply, but in previous post i mentioned that i have cast string to date in sql query, but this time i m saving date in encrypted format and it can't decrypted in sql query so i m decrypting in cs code.
is there any way to cast it to date formate after decrypting and bind with grid. Below is my code for binding data to Grid

 protected void gdshow_ItemDataBound(object sender, GridItemEventArgs e)
        {
            try
            {
                if (isExcelExport && e.Item is GridDataItem)
                {
                    foreach (TableCell cell in e.Item.Cells)
                    {

                        cell.Style["mso-number-format"] = @"\@";

                    }
                }


                if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
                {
                    GridDataItem dataBoundItem = e.Item as GridDataItem;



                    foreach (GridColumn column in dataBoundItem.OwnerTableView.RenderColumns)
                    {
                        if (column.HeaderText.Trim().ToLower().Contains("date"))
                        {
                          
                            dataBoundItem[column.UniqueName].Text = dataBoundItem[column.UniqueName].Text.Replace(" 12:00:00 AM", "").Replace("1/1/1900", "");
                        }
                    }



                }
            }
            catch (Exception)
            {


            }

        }

 

 

Thank yoiu

0
Konstantin Dikov
Telerik team
answered on 29 Dec 2016, 06:37 AM
Hi Shafqat,

Can you please elaborate what you mean by "encrypted dates format" and why you need to store the values in such manner in your database? As for the sorting, the RadGrid will sort the values based on the values in the DataSource, so the only options that you have is to either change the database column to store the values as dates or fill a DataTable with the original values and modify them before setting that DataTable as a DataSource of the grid.


Regards,
Konstantin Dikov
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Huxu
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Shafqat
Top achievements
Rank 1
Konstantin Dikov
Telerik team
Share this question
or