optimization for SPArrangeChoices

Oct 1, 2010 at 4:16 PM
Edited Oct 1, 2010 at 4:18 PM

Hi Marc,

SPServices is an outstanding tool, I am using it a ton, so thank you!

I have a complicated form that has >6 choice fields that I am re-arranging using $().SPServices.SPArrangeChoices -- my question is if you would be willing to optimize this slightly by allowing a listName/listGuid to be passed as an option to it, to cut in half the number of web services calls.  For each choice field being re-arranged it makes two web services calls, which could be cut in half by allowing an optional listName/listGuid to be supplied by the caller.

Attached is my very small change the code to accomplish this:

 

	$.fn.SPServices.SPArrangeChoices = function (options) {

		var opt = $.extend({}, {
			listName: "",					// the list name of the current form.
			columnName: "",					// The display name of the column in the form
			perRow: 99,						// Maximum number of choices desired per row.
			randomize: false				// If true, randomize the order of the options
		}, options);

		var columnFillInChoice = false;
		var options = new Array();
		var out;
		
		// Get information about columnName from the list to determine if we're allowing fill-in choices
		$().SPServices({
			operation: "GetList",
			async: false,
			listName: ( opt.listName != "" ) ? opt.listName : listNameFromUrl(),
			completefunc: function(xData, Status) {

 

The changes I made are highlighted in red.  Thanks for considering this Marc.

Nathan

 

 

Coordinator
Oct 2, 2010 at 1:45 AM

Nathan:

This is a great suggestion, and I'm going to include in in the next alpha which I'll release tonight. I'd appreciate any testing you could do!

Thanks,
M.

Coordinator
Oct 2, 2010 at 1:45 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Coordinator
Oct 2, 2010 at 1:48 AM

p.s. This also will give people the option of using this function outside the context of the list, so it's a double win.

M.