:: Forum >> Version 1 >>

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.

/javascript.forum.1127.13/

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
Wednesday, September 8, 2004
Anyone else run across this problem?
Dennis
Monday, September 13, 2004
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
Friday, September 17, 2004
Hi,

Here is the template code that I use

if (!window.PrimaPrima=[]; 
if (!
Prima.TemplatesPrima.Templates=[]; 

Prima.Templates.StatusSelect Active.Templates.Text.subclass(); 
Prima.Templates.StatusSelect.prototype._options = new Array();

Prima.Templates.StatusSelect.create = function() 

    var 
obj this.prototype

    
//------------------------------------------------------------ 
    //Add the text value pair to the select dropdown list 
    //------------------------------------------------------------ 
    
obj.addOption = function( textvalue 
    { 
        
this._options.push( new Array( value ? value texttext) ); 
    } 

    
obj.clearOptions = function() 
    { 
        
this._options = new Array(); 
    } 
    
    
obj.getOptions = function() 
    { 
        return 
this._options;
    } 

    
// editor is not part of the template, 
    // there is only one single instance of editor object. 
    
var editor = new Active.HTML.DIV
    
editor.setTag("select");
    
editor.setClass("templates""input"); 
    
editor.setAttribute("type""text"); 
    
editor.setEvent("onblur", function(event) { this.switchToTextModeevent ); } ); 
    
editor.setContent"options", function() 
    {
        var 
text template.getItemProperty("text");
        var 
inputOptions obj._options;

        var 
optionsHTML = new Array(); 
        for( 
i=0iinputOptions.lengthi++ )
        { 
            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.pushoTag ); 
        } 
        
        return 
optionsHTML.join(""); 
    }); 

    
// template variable provides temporary reference 
    // to the parent template during edit mode. 
    
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;

        
// we want to compare the text in the grid
        // grid display only the text
        
if(originalText != text)
        {
            
template.setItemProperty("text"text);
            
template.setItemProperty("value"value); 
            if(
obj.onChangeEvent)
            {
                
obj.onChangeEvent();
            }
        }
        
template.refresh(); 
        
template null
    }

    
obj.onChangeEvent = function()
    {
        
// alert("User must override this function to recieve the events");
    
}


    
editor.setEvent("onblur"switchToTextMode); 
}; 

Prima.Templates.StatusSelect.create(); 
 
Override the setValue function and commit the changes to the database

/****************************************************************

                        Set the cell text.

                        @param i (Index) Row index.
                        @param j (Index) Column index.

                    *****************************************************************/

                        
obj.setValue = function(valueij)
                        {
                            
// used to commit the changes
                            
var taskId taskTable.getValue(i,<%=TASK_ID_COL%>);

                            
// create HTTP request object and save the value to the database
                            
var commitChangeRequest = new Active.HTTP.Request;

                            
// URL
                            
commitChangeRequest.setURL("<%=request.getContextPath()%>/UpdateTask.do");

                            
// set request method to POST (default is GET)
                            
commitChangeRequest.setRequestMethod("POST");

                            
// set request parameters (i.e. form values)
                            
commitChangeRequest.setParameter("taskId"taskId);

                            if(
> <%=TASK_GRID_COLS%>)
                            {
                                
commitChangeRequest.setParameter("backlogDay", (j-1)-<%=TASK_GRID_COLS%>);
                                
commitChangeRequest.setParameter("duration"value);
                                
commitChangeRequest.setParameter("durationType"durationType);

                                
// send the request (async)
                                
commitChangeRequest.request();
                            }
                            else
                            {
                                switch(
j)
                                {
                                    case 
commitChangeRequest.setParameter("name"value);
                                            
// send the request (async)
                                            
commitChangeRequest.request();
                                    break;
                                    case 
commitChangeRequest.setParameter("originalUnits"value);
                                            
// send the request (async)
                                            
commitChangeRequest.request();
                                    break;
                                    case 
commitChangeRequest.setParameter("resource"value);
                                            
// send the request (async)
                                            
commitChangeRequest.request();
                                    break;
                                    case 
commitChangeRequest.setParameter("status"value);
                                            
// send the request (async)
                                            
commitChangeRequest.request();                                       
                                    break;
                                    default: 
alert("<bean:message key='error.fieldvaluechange'/>");
                                }
                            }

                            
// set event handler to process the result
                            
commitChangeRequest.response = function(text)
                            {
                                
// display a message only if the status code is other than 200
                                // alert("Alert status code " + this.getStatus());
                            
};
                        };


 
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
Sunday, September 19, 2004
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
Monday, September 27, 2004



This topic is archived.

Back to support forum

Forum search