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

How to sort column by month

5 Answers 263 Views
PivotGrid
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 11 Oct 2012, 04:10 PM

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>

 

5 Answers, 1 is accepted

Sort by
0
Marin
Telerik team
answered on 16 Oct 2012, 07:26 AM
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.
0
Neil N
Top achievements
Rank 1
Iron
Veteran
Iron
answered on 04 Mar 2013, 09:09 PM
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

0
Marin
Telerik team
answered on 07 Mar 2013, 11:44 AM
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.
0
Tim
Top achievements
Rank 1
answered on 18 Nov 2013, 02:24 PM
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.
0
Tim
Top achievements
Rank 1
answered on 18 Nov 2013, 02:27 PM
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
Tags
PivotGrid
Asked by
Chris
Top achievements
Rank 1
Answers by
Marin
Telerik team
Neil N
Top achievements
Rank 1
Iron
Veteran
Iron
Tim
Top achievements
Rank 1
Share this question
or