SPDisplayRelatedInfo modified

Nov 15, 2010 at 7:35 PM

I wanted the SPDisplayRelatedInfo  to be used for a Lookup with Picker type of column.

Also, I needed it to work on my Display Forms.

To that end, I added 2 else if cases in the dropdownCtl function

// Lookup with Picker: This will find the Lookup with Picker control
} else if((this.Obj = $("H3:contains('" + colName + "')").parent('td').next().find("textarea[name*='downlevelTextBox']")).html() != null) {
	this.Type = "L";
// Control on Display forms: this will find the lookup column on a display form
} else if((this.Obj = $("H3:contains('" + colName + "')").parent('td').next().find("a[href*='DispForm.aspx?ID=']")).html() != null) {
	this.Type = "D";

 

And corresponding cases in the SPDisplayRelatedInfo function

case "L":
	columnSelect.Obj.bind("propertychange", function() {
		showRelated(opt);
	});
	// Fire the change to set the allowable values
	columnSelect.Obj.trigger("propertychange");
	break;
case "D":
	showRelated(opt)
	break;

And in the  showRelated function

 

case "L":
	columnSelectSelected = columnSelect.Obj.attr("value");
	// Check to see if at least opt.numChars have been typed (if specified)
	if(opt.numChars > 0 && columnSelectSelected.length < opt.numChars) return; 		//Not sure if this is needed in thise case
	break;
case "D":
	var tempStr = columnSelect.Obj.attr("href")
	columnSelectSelected = tempStr.substring(tempStr.indexOf('ID=')+3,tempStr.indexOf('\&',tempStr.indexOf('ID=')))
	break;

 

 

This may not be the most elegant code as I just started learning javascript and jquery, but it seems to work for me at least.

Seemed like this would be a valuable addition to the published library.

 

Oh, great set of tools by the way. Thanks for sharing.

 

Peter-Dave

Coordinator
Nov 17, 2010 at 3:43 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.