SPDisplayRelatedInfo Date Format

Dec 17, 2009 at 12:10 AM

Marc

WOW you've been busy! I just upgraded from 3.2 to 4.7 and need to spend some time learning all the new functionality. Congrats on the success. :-) I have two questions for you.

1. Have you include the greater than 20 item fix in the latest version? This particular issue is killing me. code such as: var BT=$('select[title=Book Title] option:selected').text(); works and as soon as the list increase past 20 the control changes and the code no longer works. If you haven't added the fix, do you know  when?

 

2. I would like to reformat the date that is displayed by using SPDisplayRelatedInfo from Year-Month-Day to the usual Month-Day-Year. Do you have any suggestions on how to accomplish this?

 

Keep up the great work.

Marcus

 

Coordinator
Dec 17, 2009 at 1:05 AM

Marcus:

You've been away from the party for a while. Nice to hear from you.

Good news on both fronts:

  1. SPCascadeDropdowns now works with any combination of simple dropdowns (<20), complex dropdowns (20+), and multi-select columns.  This means any of the three types for the parentColumn or childColumn.  I should make this a little clearer in the documentation.
  2. SPDisplayRelatedInfo now has (along with 3 of the other functions) a completefunc option. You can pass in a function name or function code to do some postprocessing on the results.  However, shouldn't your locale settings take care of the date formatting for you?

Let me know what other question you might have, and welcome to v0.4.7!

M.

Dec 17, 2009 at 1:29 AM

Marc

You know you got me thinking here. The issue is not with your code concerning the 20+ items in a list. I'm using SPDisplayRelatedInfo and it works for every item I select out of the total 25. The problem occurs when I try to read the selected value using jquery when its more than 20 item since it changes to _Select. I realize this isn't your issue but could you provide assistance on how to access _Select using jquery?

 

Thanks

Marcus

 

Coordinator
Dec 17, 2009 at 2:23 AM

What is it that you're trying to do with the selected value?  You may be able to reliably work with it in the completefunc.

M.

Dec 31, 2009 at 1:53 PM
Edited Dec 31, 2009 at 1:53 PM

Marc

I would like to use the completefunc to modify the formatting of the two date time columns (these are the relatedColumns for SPDisplayRelatedInfo). The date/time format that SPDisplayRelatedInfo returns is: YYYY-MM-DD 24:00:00 and I would like to use the typical: MM-DD-YYYY 12:00:00. Do you have any examples on manipulating the formatting on relatedColumns using completefunc?

Thanks and Have a Happy 2010

Marcus

Coordinator
Dec 31, 2009 at 3:34 PM

Marcus:

I don't have an example handy, but the JavaScript date functions ought to let you reformat the date/time fairly easily.  The output from the SPDisplayRelatedInfo function is wrapped in a div with the id = "showRelated_" + encodeColumn(opt.columnName).  (Sort of inconsistent now that I look at it.  It probably should be "SPDisplayRelatedInfo_" + encodeColumn(opt.columnName).)  This should help with your selectors to change the date/time values.

M.

Jan 4, 2010 at 1:21 PM

Marc

I have been successful in accessing the values from SPDisplayRelatedInfo. My delimina is that I need completefunc to fire every time the values changes.  The columns names will never change.

Thanks

Marcus

Coordinator
Jan 4, 2010 at 1:37 PM

That's actually what the completefunc option is there for in $().SPServices.SPDisplayRelatedInfo (as well as $().SPServices.SPCascadeDropdowns, $().SPServices.SPLookupAddNew, and $().SPServices.SPRequireUnique).  It will fire on every completion of a change in the value of columnName.

M.

Jan 4, 2010 at 2:10 PM

If thats the case which I am very happy to hear then I'm sure I'm doing something wrong. Here is a code snippet.

//Include Room Location, Course Start Time and End Time 
			//when a Course is selected
			$().SPServices.SPDisplayRelatedInfo({
				columnName: 'Course Title',
				relatedList: 'Courses',
				relatedListColumn: 'Title',
				relatedColumns:['Location','EventDate','EndDate'],
				completefunc: formatResults(),
				debug: true
			});
				
			
			function formatResults(){
			
			alert('formatResults');

			}	
For every course that I select (30 courses) the the value for location, EventDate and EndDate change but formatResults is not raised every time. What am I missing.
Thanks

Coordinator
Jan 4, 2010 at 2:15 PM

Remove the parentheses after formatResults in the completefunc.  You want to pass the function as a pointer rather than calling it.

completefunc: formatResults,

M.