Jump to content

Editable dropdown lists


SeanDay

Recommended Posts

Hi,

 

 

Is it possible to have a dropdown list for parameters (e.g. single-select query) that the user can also enter free text on?

 

 

I cannot see this in the system but guess I can maybe do it by modifying the parameter .jsp file.

 

 

Is this the only way?

 

 

Thanks,

 

 

Sean

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

I have found a way of doing what I wanted.

 

 

I have created a copy of the DefaultParametersForm.jsp file and modified it to add a link next to the dropdown list. This link calls a javascript function that hides the list and displays an edit field. The function also changes the link text/title and swaps the names of the list and text field so the value will be used of whichever one is selected..

 

 

The code modifications are show below:

 

 

Code:

function toggleEditable(linkID,listID,textID,fieldName)
{
var linkObj = document.getElementById(linkID);
var listObj = document.getElementById(listID);
var textObj = document.getElementById(textID);

if(linkObj.firstChild.nodeValue == 'Allow Editing')
{
linkObj.firstChild.nodeValue = 'Show List';
linkObj.title="Click here for a list of values to select from" ;
listObj.style.display = "none";
listObj.name=fieldName+"_HIDE";
textObj.style.display = "inline";
textObj.name=fieldName;
textObj.focus();
}
else
{
linkObj.firstChild.nodeValue = 'Allow Editing';
linkObj.title="Click here to enter text manually" ;
listObj.style.display = "inline";
listObj.name=fieldName;
textObj.style.display = "none";
textObj.name=fieldName+"_HIDE";
}
}

 

 

I then modify any list items I want (e.g. below is the modification to the file for the single-select-query section):

 

 

Code:
[code]
<c:when test="${control.type == 4}"> <%-- Single value selected from list created from a query: InputControl.TYPE_SINGLE_SELECT_QUERY --%>
<td align="right">${control.label}  </td>
<td>
<select name="${inputName}" id="${inputName}_LIST" class="fnormal" <c:if test="${readOnly}">disabled</c:if>
onchange="${onInputChange}">
<c:if test="${!control.mandatory}"><option value="" /></c:if>
<c:forEach items="${wrapper.queryResults}" var="item" varStatus="status">
<option value="${item.key}" <c:if test="${item.key == wrapper.value}">selected</c:if>>${item.value[1]}</option>
</c:forEach>
</select>
<input name="${inputName}" class="fnormal" type="text" id="${inputName}_TEXT" style="display:none">
<a id="${inputName}_LINK" title="Click here to enter text manually" target=_self href="javascript:toggleEditable('${inputName}_LINK', '${inputName}_LIST', '${inputName}_TEXT', '${inputName}');">Allow Editing</a>
</td>
</c:when>

 

 

I have not done too much testing on this yet but it seems to work OK. It would have been nicer to have been able to add new InputControl types for each type of list item to specify if an editable item was wanted but that might be going beyond my abilities..

 

 

Sean

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...