How to sort column by month

6 posts, 0 answers
  1. Chris
    Chris avatar
    1 posts
    Member since:
    Mar 2011

    Posted 11 Oct 2012 Link to this post

    Within my data source I can only retrieve month names.   I need the month column sorted by when they occur in the year not alphabetically.  

    So I need the months to show January, February, etc not April, August etc
    Can anyone help?   Here is how I'm referencing the month column name:

     

    <telerik:PivotGridColumnField DataField="month_name" DataFormatString="{0}"  UniqueName="month_name" >

     </telerik:PivotGridColumnField>

     

  2. Marin
    Admin
    Marin avatar
    1045 posts

    Posted 16 Oct 2012 Link to this post

    Hi,

     In the new version RadPivotGrid will provide an option for binding to custom type objects that implement IComparable which will allow you to sort and filter the fields according to your custom criteria.

    I see that you have also opened a support ticket on the same subject, if you do not mind we will continue any further communication there in order to avoid duplicates posts.

    All the best,
    Marin
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Neil N
    Neil N avatar
    75 posts
    Member since:
    Aug 2012

    Posted 04 Mar 2013 Link to this post

    Is there an example/demo for this?  For example, I'd like to sort a Category field by the sort order specified in the database, not by alphabetical order.  Right now, as a work-around I'm doing this in SQL: REPLICATE('0', 2 - LEN(CAST(c.nOrder AS varchar(2)))) + CAST(c.nOrder AS varchar(2)) + ' ' + c.sName Category

  5. Marin
    Admin
    Marin avatar
    1045 posts

    Posted 07 Mar 2013 Link to this post

    Hello,

     You can find an online example here:
    http://demos.telerik.com/aspnet-ajax/pivotgrid/examples/groupingbycustomobject/defaultcs.aspx
    In the demo the Category field implements IComparable, you can use the same approach to provide custom criteria for sorting the months in your case.

    Kind regards,
    Marin
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  6. Tim
    Tim avatar
    85 posts
    Member since:
    Aug 2008

    Posted 18 Nov 2013 Link to this post

    Actually, I do this now without the latest version.  Basically, in my Data source I would have a column/property for "MonthNo" and bind that to one of the Fields, so that sorting works as expected.  Next, in the Field template, I would add a Label control which Binds to a function in the Web Forms code-behind:

    <CellTemplate>
            <asp:Label runat="server" Text="<%# Me.GetMonthName(Container.DataItem)%>" />
    </CellTemplate>

    And that's it!

    You'll have to refer to my other work-around on the PivotGrid losing Templates on PostBacks in order to resolve that issue.
  7. Tim
    Tim avatar
    85 posts
    Member since:
    Aug 2008

    Posted 18 Nov 2013 Link to this post

    Here's a link on how to fix the PivotGrid losing it's CellTemplates on PostBacks.

    http://www.telerik.com/community/forums/aspnet-ajax/pivotgrid/template-is-lost-when-fieldreorder-command-is-fired.aspx
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017