Dropdown box doesn't save section
The dropdown box (Select Cell template) doesn't save its values once you change them.
I can pick and choice them find as Marlon Domingos set it up.
http://www.activewidgets.com/messages/1127-13.htm
But once I pick my new setting, and save my xml data, the values still are the default ones that i'm grabbing off my sql.
Dennis
September 8,
Anyone else run across this problem?
Dennis
September 13,
I still can't get a dropdown box to save back to an XML table. Has anyone else had success with this? I can pick it find, but when I save the grid, the old value is always still there.
Dennis
September 17,
Hi,
Here is the template code that I use
if (!window.Prima) Prima=[];
if (!Prima.Templates) Prima.Templates=[];
Prima.Templates.StatusSelect = Active.Templates.Text.subclass();
Prima.Templates.StatusSelect.prototype._options = new Array();
Prima.Templates.StatusSelect.create = function()
{
var obj = this.prototype;
obj.addOption = function( text, value )
{
this._options.push( new Array( value ? value : text, text) );
}
obj.clearOptions = function()
{
this._options = new Array();
}
obj.getOptions = function()
{
return this._options;
}
var editor = new Active.HTML.DIV;
editor.setTag("select");
editor.setClass("templates", "input");
editor.setAttribute("type", "text");
editor.setEvent("onblur", function(event) { this.switchToTextMode( event ); } );
editor.setContent( "options", function()
{
var text = template.getItemProperty("text");
var inputOptions = obj._options;
var optionsHTML = new Array();
for( i=0; i< inputOptions.length; i++ )
{
var oTag = new Active.System.HTML();
var val = inputOptions[i][0];
var txt = inputOptions[i][1];
oTag.setTag("option");
oTag.setAttribute( "value", val );
oTag.setContent("text",inputOptions[i][1]);
if ( text==txt )
{
oTag.setAttribute( "selected","true" );
}
optionsHTML.push( oTag );
}
return optionsHTML.join("");
});
var template;
function switchToEditMode()
{
template = this;
template.element().style.padding = 0;
template.element().innerHTML = editor;
editor.element().focus();
}
obj.setEvent("ondblclick", switchToEditMode);
function switchToTextMode()
{
var originalText = template.getItemProperty("text");
var value = editor.element().value;
var selectedIndex = editor.element().selectedIndex;
var text = editor.element().options[selectedIndex].text;
if(originalText != text)
{
template.setItemProperty("text", text);
template.setItemProperty("value", value);
if(obj.onChangeEvent)
{
obj.onChangeEvent();
}
}
template.refresh();
template = null;
}
obj.onChangeEvent = function()
{
}
editor.setEvent("onblur", switchToTextMode);
};
Prima.Templates.StatusSelect.create();
Override the setValue function and commit the changes to the database
obj.setValue = function(value, i, j)
{
var taskId = taskTable.getValue(i,<%=TASK_ID_COL%>);
var commitChangeRequest = new Active.HTTP.Request;
commitChangeRequest.setURL("<%=request.getContextPath()%>/UpdateTask.do");
commitChangeRequest.setRequestMethod("POST");
commitChangeRequest.setParameter("taskId", taskId);
if(j > <%=TASK_GRID_COLS%>)
{
commitChangeRequest.setParameter("backlogDay", (j-1)-<%=TASK_GRID_COLS%>);
commitChangeRequest.setParameter("duration", value);
commitChangeRequest.setParameter("durationType", durationType);
commitChangeRequest.request();
}
else
{
switch(j)
{
case 0 : commitChangeRequest.setParameter("name", value);
commitChangeRequest.request();
break;
case 1 : commitChangeRequest.setParameter("originalUnits", value);
commitChangeRequest.request();
break;
case 2 : commitChangeRequest.setParameter("resource", value);
commitChangeRequest.request();
break;
case 3 : commitChangeRequest.setParameter("status", value);
commitChangeRequest.request();
break;
default: alert("<bean:message key='error.fieldvaluechange'/>");
}
}
commitChangeRequest.response = function(text)
{
};
};
I do not know if this is the best way to do it. but this is the way I have done it; might give you an idea as well
Thanks
Bhaskar
September 19,
Where is the do i put the code to override the setvalue function? And what is the purpose, it seems to work with just the template in place now.
BTW, thanks for the template. Looks good.
Dennis
September 27,