Customisation Title | Alphabetically Sort Forms Views in the Workflow Step screen |
---|---|
Purpose of Customisation | Sort the WebForm views avavilable to be linked to a Workflow step alphabetically rather than in the order they were added to the system. |
Author | Greg Griffiths |
Date of Customisation | 12 September 2003 |
Covers Livelink | Livelink 9 |
Livelink Modules | FormWFPaint |
Affected Templates | \formwfpaint\html\tforms.html |
Customisation Format | HTML |
Download Here | Download as a ZIP file |
This customisation sorts the HTML WebForm views that you have attached to a given template in alphabetical order when they are displayed in the screen that allows you to attach one or more WebForm Views to a Workflow Step.
The customisation is provided by the addition of a javascript sort function into the template. This function runs directly after the list of available WebForm views has been populated onto the form, and as such completes before the user has a chance to select one.
;if ( IsDefined( formData.Views ) )
<SELECT NAME="FormView_`formData.ID`" SIZE="`Length( formData.Views.Keys )`" MULTIPLE ONCHANGE="markTaskEditDirty();">
;for ( i = 1; i <= Length( formData.Views.Keys ); i += 1 )
;if ( Type( value ) == ListType )
;checked = ( formData.Views.Vals[ i ] in value ) ? 'SELECTED' : ''
;else
;checked = ( formData.Views.Vals[ i ] == value ) ? 'SELECTED' : ''
;end
<OPTION VALUE='`%LformData.Views.Vals[ i ]`' `checked`>`%LformData.Views.Keys[ i ]`</OPTION>
;end
</SELECT>
<script language="javascript">
var arr_optionsValue = new Array(); // array to hold the Value of the OPTIONS
var arr_optionsText = new Array(); // array to hold the Text of the OPTIONS
var ds; // Index of current selected Option
var theDD; // reference to the Drop Down
// if we are creating a form
theDD=document.myForm.FormView_`formData.ID`
// populate the array
for (count=0;count<theDD.options.length;count++)
{
arr_optionsText[count] = theDD.options[count].text;
// if this is the selected one
if (theDD.options[count].defaultSelected)
{
ds=count;
}
}
// sort them
arr_optionsText.sort();
// get the correct values
for (i=0;i<arr_optionsText.length;i++)
{
for (j=0;j<theDD.options.length;j++)
{
if (theDD.options[j].text==arr_optionsText[i])
{
arr_optionsValue[i]=theDD.options[j].value;
}
}
}
// empty the dd
theDD.options.length=0;
// repopulate the list
for (i=0;i<arr_optionsText.length;i++)
{
// if the selected element
if (i==ds)
{
theDD.options[i]= new Option(arr_optionsText[i],arr_optionsValue[i],true,true);
}
else
{
theDD.options[i]= new Option(arr_optionsText[i],arr_optionsValue[i]);
}
}
</script>
;end
Before | After |
---|