Hello Folks, This article is regarding creating “SharePoint Group by View with Order by on DateTime Field” for list or library in SharePoint 2010. First, lets us have a look on what is the need to create this kind of view?
To create Group by view, SharePoint provides out of box settings in Group by node in view setting where column to group by can be easily defined. With Group by view SharePoint shows its own behavior and it will do order by on the same column on which we have enabled Group by. Below is the simplest example to understand this.
Suppose we have a list named as 'Ask Us' with columns ‘Question’, ‘Answer’, ‘Created’, ‘Modified’. Now we want to show a list of questions in expandable-collapsible manner with ascending order on modified date. To achieve that i have selected a ‘Question’ column in group by setting and a ‘Modified’ Column in sort order settings so its output will look like below.
This is incorrect as per our requirement because we want to do order by on ‘Modified’ column not on ‘Question’ column.
In this article, we will see most easiest way to achieve our requirement step by step.
=TEXT(Modified,"yyyy")&TEXT(Modified,"mm")&TEXT(Modified,"dd")&TEXT(Modified,"hh:mm:ss")&Question
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $("tr[id='group0']").each(function(){ var p = $(this); p.html( p.html().replace( /\d{10}:\d{2}:\d{2}/, ' ' ) ) }); }); </script>
Hope it helps!!!! Best Regards, Joydeep K.
Richard Mueller edited Revision 1. Comment: Removed extra space in tag "SharePoint 2010", added language tag
Great job...!!!