RadGrid Sorting doesn't work.

6 posts, 0 answers
  1. Huxu
    Huxu avatar
    1 posts
    Member since:
    Dec 2014

    Posted 05 Jan 2015 Link to this post

    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!











  2. Pavlina
    Admin
    Pavlina avatar
    6187 posts

    Posted 08 Jan 2015 Link to this post

    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.

     
  3. Shafqat
    Shafqat avatar
    7 posts
    Member since:
    Nov 2016

    Posted 28 Dec 2016 Link to this post

    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

  4. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    2466 posts

    Posted 28 Dec 2016 Link to this post

    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.
  5. Shafqat
    Shafqat avatar
    7 posts
    Member since:
    Nov 2016

    Posted 28 Dec 2016 in reply to Konstantin Dikov Link to this post

    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

  6. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    2466 posts

    Posted 29 Dec 2016 Link to this post

    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.
Back to Top