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

Show full datetime in column but group by date only

5 Answers 254 Views
GridView
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 29 Jul 2010, 03:10 AM
I'm using a databound gridview, binding to a custom list of "entity" type.  The datetime field I want to group by is called Created.

    public partial class frmSearchResults : Form
    {
        private List<Entity> Results;
 
        public frmSearchResults(List<Entity> SearchResults)
        {
            InitializeComponent();
            Results = SearchResults;
            gridSearchResults.DataSource = Results;
            gridSearchResults.BestFitColumns();
        }
}

I've found some related posts in the forum but none have solved my issue yet (I'm new to rad controls so I may very well be missing or misunderstanding something).  One post mentioned CellTemplates but I'm not sure to go about that and that solution was in the context of a non bound grid.

Thanks,
John

5 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 03 Aug 2010, 07:53 PM
Hello John,

Thank you contacting us.

Currently we have some issues with our custom grouping functionality. We will try to address them for our Q2 SP1 due in the beginning of the next week. I apologize for the inconvenience that this may cause.

However, your case is more specific. To make it work you should make a custom implementation where you have a hidden column that holds the date in a desired format, and when you try to group by  the date column, you will actually should group by the hidden one. 

Should you need help with implementing this scenario, do not hesitate to contact us back, once the SP1 is released.
 
Kind regards,
Stefan
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
0
John
Top achievements
Rank 1
answered on 06 Aug 2010, 01:22 AM
Thanks for the info.  I'll keep an eye out for updates.

How do I go about adding such a calculated column to a databound grid?  I've tried a few ways to no avail.

Thanks
0
Julian Benkov
Telerik team
answered on 11 Aug 2010, 07:11 PM
Hello John,

I would like to apologize for the introduced inconvenience. 

Our team continues with the fixes and code refactoring of the CustomGrouping data operation. However, all reported issues were postponed for the upcoming Q2 2010 Service Pack 2 release which is due to the first half of September. 

Currently you can use solution with the hidden column. Please refer to the attached example project.

All the best,
Julian
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
0
Barry
Top achievements
Rank 1
answered on 16 Aug 2010, 11:13 AM
I have looked at the code in the file (customgrouping.zip) attached to the previous post. The line:

groupDescriptor.Format = "DateTimeColumn: {1}";

appears to be invalid as there is no Format property for groupDescriptor.

I wish to change the format of the Group By row. I tried using the groupDescriptor.Expression using the same syntax that uesd to work for earlier versions of Telerik controls, but it made no difference to the result. The code that I used is as follows:

private void rgvTest_GroupByChanging(object sender, GridViewCollectionChangingEventArgs e)
           {
               Telerik.WinControls.Data.GroupDescriptor groupDescriptor = e.NewItems[0] as Telerik.WinControls.Data.GroupDescriptor;
               if (groupDescriptor == null)
               {
                   return;
               }
 
               for (int i = 0; i < groupDescriptor.GroupNames.Count; i++)
               {
                   if (groupDescriptor.GroupNames[i].PropertyName == "Site_ID")
                   {
                       e.Cancel = true;
                       groupDescriptor.GroupNames[i].PropertyName = "SiteName";
                       groupDescriptor.Expression = "[SiteName] as [Site Name], Count([Site_ID]) as [Items] Group By [SiteName]";
                       //groupDescriptor.Format = "DateTimeColumn: {1}";
                       this.rgvTest.GroupDescriptors.Add(groupDescriptor);
                   }
               }
           }

How do I specify an Expression?


Barry
0
Stefan
Telerik team
answered on 17 Aug 2010, 10:09 AM
Hi Barry,
 
Thank you for writing.

The Format property of the GroupDescriptor was introduced in Q2 2010 SP1 and this is why you cannot see it. Unfortunately, in your version Q2 2010 there is no way to access or use this property. 

Feel free to update to our latest version in order to access this functionality. If you need any assistance migrating your project, do not hesitate to contact us.

I hope you find this information helpful.
 
All the best,
Stefan
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
GridView
Asked by
John
Top achievements
Rank 1
Answers by
Stefan
Telerik team
John
Top achievements
Rank 1
Julian Benkov
Telerik team
Barry
Top achievements
Rank 1
Share this question
or