3.0.0

How to edit a column when call onchange event of checkbox in the same row

Hello Guys

I'm trying to call the editor template method "switchToEditMode" when the user triggered the onchange event of the checkbox template on the same row, other column.

Please Alex, help me! Follow is my source code:

<script type="text/javascript">
    var pat_edi = new Array(12,2);
    if (!window.My) My=[]; 
    if (!My.Templates) My.Templates=[]; 
    My.Templates.Input = Active.Templates.Text.subclass(); 
    My.Templates.Input.create = function()
    { 
        var obj = this.prototype; 
        var editor = new Active.HTML.INPUT; 
        editor.setClass("templates", "input"); 
        editor.setAttribute("type", "text"); 
        editor.setAttribute("maxlength", "15"); 
        editor.setAttribute("valant",0); 
        editor.setEvent("onkeydown", function(){return true;})
        var template; 
        function switchToEditMode()
        {
            if (template) { 
                switchToTextMode() 
            } 
            template = this; 
            template.element().style.padding = 0; 
            template.element().innerHTML = editor;
            editor.element().focus();
            $('tag51').getAttribute('valant'); 
            $('tag51').value = '';
            x_grid.disable();
            editando=true;
        }		
        obj.setEvent("ondblclick", switchToEditMode); 
    
        function switchToTextMode()
        { 
            var value =  f_grid[10].dataToText(editor.element().value);
            var value_=  editor.element().value;
            var originalVal = template.getItemProperty("text"); 
            if(originalVal != value)
            { 
                template.setItemProperty("text", value);
                template.setItemProperty("value", value_); 
                x_grid.enable();
                setTimeout("x_grid.element().focus();",2000);
            } 
            template.refresh(); 
            template = null; 
        } 
        editor.setEvent("onblur", switchToTextMode); 
        editor.setEvent("onkeydown", function(event)
        {
            key = event.keyCode;
            if(key==13){$('tag51').blur(); return;}
            if ((key >= 35 && key <= 40) || key == 46)
                return true;			
        });
        editor.setEvent("onkeyup", function(){mascara($('tag51'),'.',' ',pat_edi,true); });
        
    }; 
    My.Templates.Input.create();
    
    if (!window.My) My=[];
    if (!My.Templates) My.Templates=[];
    
    // ****************************************************************
    //     Checkbox Cell Template.
    // ****************************************************************
    
    My.Templates.Checkbox = Active.System.Control.subclass();
    
    My.Templates.Checkbox.create = function(){
    
      var obj = this.prototype;
      
      obj.defineModel("checked");
      obj.defineCheckedProperty("true", "1");
      obj.defineCheckedProperty("false", "0");
      
      obj.setClass("templates","checkbox");
    
      var checkbox = new Active.HTML.INPUT;
      checkbox.setClass("input","checkbox");
      checkbox.setClass("checkbox", function(){return this.getColumnProperty("index")});
      checkbox.setAttribute("type","checkbox");
      checkbox.setAttribute("checked", function(){
        return (this.getItemProperty("text") == this.getCheckedProperty("true"))
      });
    
      function toggleValue(){
        var originalVal = this.getItemProperty("text");
        var newValue = (originalVal == this.getCheckedProperty("true")) ? this.getCheckedProperty("false") : this.getCheckedProperty("true");
        this.setItemProperty("text", newValue);
        this.refresh();
      }
      
      checkbox.setEvent("onclick", toggleValue);
    
      obj.setContent("checkbox", checkbox);
    
    };
    
    My.Templates.Checkbox.create(); 	 
    
    var str = new Active.Formats.String;
    var num = new Active.Formats.Number;
    num.setTextFormat("###,###.##");

    datos = [["","Pagar","GuaranĂ­","21/08/2008","Fact","001-001-0000254","51","02/09/2008",521524532152.21,"0",0]];
    
    var col = ["ID_tit","Tipo","Moneda","Fecha","E.D.","Documento","Cuota","Vencimiento","Saldo","","Monto a Procesar"];		
    f_grid = [str, str, str, str, str, str, str, str, num, str, num];
    
    var template = new My.Templates.Input; 
    
    ck = new My.Templates.Checkbox;
    ck.setCheckedProperty('true', '1');
    ck.setCheckedProperty('false', '0');
    
    var x_grid = new Active.Controls.Grid;
    x_grid.setRowProperty("count", datos.length);
    x_grid.setColumnProperty("count", col.length);
    x_grid.setSelectionProperty("multiple", true);

    x_grid.setDataText(function(i, j){return f_grid[j].dataToText(datos[i][j]);});
    x_grid.setDataValue(function(i, j){return datos[i][j];})
    x_grid.setColumnProperty("text", function(i){return col[i]});
    
    x_grid.getTemplate("row", 0).setStyle("background-color", xcol);
    x_grid.setRowHeaderWidth("22px");
    x_grid.setColumnHeaderHeight("20px");
    x_grid.setColumnValues([1,2,3,4,5,6,7,8,9,10]);	
    x_grid.setColumnTemplate(ck,9);
    x_grid.setColumnTemplate(template,10);
    
    x_grid.setAction("restoreParentFocus", function(){this.element().focus();}); 
    
    document.write(x_grid); x_grid.setSelectionIndex(0);
        
    x_grid.disable = function() {	
        this.setAttribute('enable',false);
        
        function _disable(oObject, sEventName) {
        oObject["_" + sEventName] = oObject.getEvent(sEventName);
        oObject.setEvent(sEventName, arti);
        }
        
        _disable(this, "onkeydown" );
        _disable(this, "onmousewheel"); 
        _disable(this.getTemplate("row"), "onclick" );
        
        var oTmp = this.getTemplate("top/item");
        _disable(oTmp, "onmousedown" ); 
        _disable(oTmp.getContent("div"), "onmousedown" );
        _disable(this.getTemplate("layout").getContent("scrollbars"), "onscroll");
    };
    
    x_grid.enable = function() {
        if (typeof this.getAttribute('enable') == 'undefined' || this.getAttribute('enable')==true) {return;}
        this.setAttribute('enable',true);
    
        function _enable(oObject, sEventName) {
        oObject.setEvent(sEventName, oObject["_" + sEventName]);
        }
    
        _enable(this, "onkeydown" );
        _enable(this, "onmousewheel");
        _enable(this.getTemplate("row"), "onclick" );
    
        var oTmp = this.getTemplate("top/item");
        _enable(oTmp, "onmousedown" );
        _enable(oTmp.getContent("div"), "onmousedown" );
        _enable(this.getTemplate("layout").getContent("scrollbars"), "onscroll");
    };	
    
    function arti(){if (editando){return true;} else { return false;}}	
</script>



Thanks
Esteban Maidana
July 28,

This topic is archived.

See also:


Back to support forum

Search

Version 2

Looking for AW 2.6 ?
The old site is here.