kp_brown

Good afternoon,

I'm using the starter site as a base for a production site and I'd like to know if anyone has had issue with the variant property (Color, Size) dropdownlists. I want the size list to order by size (S,M, L, XL) but it keeps ordering alphabetically. Any ideas

TIA,

KP


Re: Commerce Server 2007 Commerce Server Starter Site

J-P Soulieres - Cactus Commerce

I think inside the ProductVariantChooser control (CommerceComponent project), there is code to sort alpabetically. You might need to change that for your needs.

J-P





Re: Commerce Server 2007 Commerce Server Starter Site

kp_brown

J-P,

Any idea what part of the code in which that would be located I've stepped through most of that code and haven't found where the ordering is located.

Thanks, Ken




Re: Commerce Server 2007 Commerce Server Starter Site

J-P Soulieres - Cactus Commerce

Notice the "options.Sort(new SelectOption.SelectOptionComparator());" in the RenderList method...

/// <summary>

/// Renders a list box.

/// </summary>

/// <param name="writer">HtmlTextWriter to use as output.</param>

/// <param name="name">The name of the control.</param>

/// <param name="options">List of SelectOptions to render in the list.</param>

private void RenderList(HtmlTextWriter writer, string name, List<SelectOption> options)

{

string uniquePropertyName = this.GetUniquePropertyName(name);

writer.AddAttribute(HtmlTextWriterAttribute.Name, uniquePropertyName);

writer.AddAttribute(HtmlTextWriterAttribute.Id, uniquePropertyName);

// A list box is a select element with a size > 1

if (this.UseListBox)

{

// ensure at least 2 lines

int count = Math.Max(options.Count, 2);

writer.AddAttribute(

HtmlTextWriterAttribute.Size, count.ToString(CultureInfo.InvariantCulture));

}

this.ListBoxStyle.AddAttributesToRender(writer);

writer.RenderBeginTag(HtmlTextWriterTag.Select);

options.Sort(new SelectOption.SelectOptionComparator());

foreach (SelectOption option in options)

{

option.Render(writer);

}

writer.RenderEndTag();

}





Re: Commerce Server 2007 Commerce Server Starter Site

J-P Soulieres - Cactus Commerce

Seems there is also some client Side javascript to sort the options alphabeticaly.

pvcClient.js file

Method: pvcHandleChange

...

// get the values and sort them.

var values = new Array();

for(var value in valueArray)

{

values.push(value);

}

values.sort();

...

J-P





Re: Commerce Server 2007 Commerce Server Starter Site

kp_brown

That did it. By commenting out the 'values.sort()', the list keeps everything in their original order from the stored procedure, which I had modified to order by 'rank'. Also, to change the default selected item/index, I put an if statement into the rendering code to skip over the selection sorting 'options.Sort(new blahblah())'. Now everything appears just as it's been requested. Thank you very much, J-P.

Thanks again, Ken