1

Pulled this from the web and it seems to work for the most part. However...

I have a calendar on a subsite. I want to display the events on the home page of the top level site and customize the appearance. Added a CQWP, exported it, modified it, etc. The data for each event is displaying nicely, however, grouping is not.

Steps:

  1. Created a calculated column (NiceDate) to sort the groups by date. This is a DateTime field (=TEXT([Start Time],"yyyy-mm-dd"))
  2. Exported/modified webpart to include 'NiceDate' in the AdditionalGroupAndSortFields' and 'CommonViewFields'.
  3. Grouped by NiceDate in web part properties.
  4. Created a new header .xsl template (DateHeader) to format the date.

Here is the code for the DateHeader formatting:

                <xsl:with-param name="GroupName" select="ddwrt:FormatDateTime(string(@*[name()=$Group]), 1033, 'dddd, MMM d yyyy')" />

When everything is put together the CQWP displays the header as literally "(Blank)" for each group. If I replace this select with one of the existing templates (select="@*[name()=$Group]") it displays the NiceDate as follows (String;#yyyy-mm-dd) which I do not want.

Long post, I know. But I've been banging my head against the wall trying to get this sorted out. I don't know where the problem is. Is it the calculated column formatted as a string? How would I fix this?

1 Answer 1

2

When you create a calculated column you choose what format the output should be and date is one of the options while string is the default.

Another option in your case could be substring to remove the elements of the string that you do not want:

select="substring-before(substring-after(@Group,'#'),')')"
5
  • Not sure how much this helps. What do you mean by "what form at the output"? For example, what I'm looking to do is display the group header as 'Tuesday, May 1 2014'. Feb 25, 2014 at 23:54
  • Not sure how much this helps. What do you mean by "what form at the output"? For example, what I'm looking to do is display the group header as 'Tuesday, May 1 2014'. Right now nothing is displayed except for "(Blank)". I made some changes and will see what happens, but I don't know why (Blank) is being displayed. Typically, I believe this happens when the field is empty (null). However, this is a calendar EventDate. The field is populated. Feb 26, 2014 at 0:01
  • Your first XSL example is trying to work with a date column but it looks like your calculated column is a string so that may be why you are getting blanks. The XSL example I provided could be used with your second example to remove the bit of the output that you do not want. Feb 26, 2014 at 8:50
  • Dave, thanks a bunch. Although your answer wasn't necessarily a solution, it did lead me in the right direction. I had mixed up my start time fields and was trying to pull the date from a field that was null. I decided to add an additional groupby field in my webpart (EventDate), then used it for the header. Thanks again. Feb 26, 2014 at 17:17
  • Excellent - glad you got it sorted Feb 26, 2014 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.