3.2.0

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; 

    //------------------------------------------------------------ 
    //Add the text value pair to the select dropdown list 
    //------------------------------------------------------------ 
    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;
    } 

    // 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.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(""); 
    }); 

    // 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(value, i, j)
                        {
                            // 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(j > <%=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 0 : commitChangeRequest.setParameter("name", value);
                                            // send the request (async)
                                            commitChangeRequest.request();
                                    break;
                                    case 1 : commitChangeRequest.setParameter("originalUnits", value);
                                            // send the request (async)
                                            commitChangeRequest.request();
                                    break;
                                    case 2 : commitChangeRequest.setParameter("resource", value);
                                            // send the request (async)
                                            commitChangeRequest.request();
                                    break;
                                    case 3 : 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
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,

This topic is archived.

See also:


Back to support forum