treegrid hotrow

Develop and Deploy Native Apps for Windows, OS X, Linux, Unix ...
Post Reply
tomy300
Posts: 70
Joined: Sat Nov 09, 2013 12:27 am

treegrid hotrow

Post by tomy300 »

Hi again

I tried the sample on orderManager and try to reproduce hotrow but does't work, ordermanager update row on database or delete it but I want it more simple than that, I want an empty grid
and people can add row on the fly and click a button save to save the data on the grid in a database.

but I don't understand how hotrow work it's not pretty clear and not much explanation in the API or example on this.

here example,
http://awesomescreenshot.com/04d2v9zzd0

support
Posts: 356
Joined: Sat Apr 27, 2013 9:22 am

Re: treegrid hotrow

Post by support »

   
Class('App', 'xui.Com',{
    Instance:{
        iniComponents : function(){
            // [[Code created by CrossUI RAD Tools
            var host=this, children=[], append=function(child){children.push(child.get(0));};
            
            append((new xui.UI.Pane())
            .setHost(host,"ctl_pane6")
            .setLeft(30)
            .setTop(20)
            .setWidth(180)
            .setHeight(220)
            );
            
            host.ctl_pane6.append((new xui.UI.TreeGrid())
            .setHost(host,"ctl_treegrid2")
            .setRowNumbered(true)
            .setEditable(true)
            .setHeader([{"id":"col1", "caption":"col1", "width":80, "type":"input"}])
            .setTreeMode(false)
            .setHotRowMode("show")
            .beforeHotRowAdded("_ctl_treegrid2_beforehotrowadded")
            );
            
            append((new xui.UI.SButton())
            .setHost(host,"ctl_sbutton7")
            .setLeft(70)
            .setTop(260)
            .setWidth(90)
            .setCaption("Get Data")
            .onClick("_ctl_sbutton7_onclick")
            );
            
            return children;
            // ]]Code created by CrossUI RAD Tools
        },
        // To determine whether to add this row or not
        _ctl_treegrid2_beforehotrowadded:function (profile, row, leaveGrid){
            if(_.get(row,["cells","0","value","length"])){
                return true;
            }else{
                return false;
            }
        },
        _ctl_sbutton7_onclick:function (profile, e, src, value){
            var ns = this,
                data = ns.ctl_treegrid2.getRows("min");
            xui.echo(data);
        }
    }
});
Class('App', 'xui.Com',{
    Instance:{
        iniComponents : function(){
            // [[Code created by CrossUI RAD Tools
            var host=this, children=[], append=function(child){children.push(child.get(0));};
            
            append((new xui.UI.Pane())
            .setHost(host,"ctl_pane6")
            .setLeft(30)
            .setTop(20)
            .setWidth(180)
            .setHeight(220)
            );
            
            host.ctl_pane6.append((new xui.UI.TreeGrid())
            .setHost(host,"ctl_treegrid2")
            .setRowNumbered(true)
            .setEditable(true)
            .setHeader([{"id":"col1", "caption":"col1", "width":80, "type":"input"}])
            .setTreeMode(false)
            .setHotRowMode("show")
            .beforeHotRowAdded("_ctl_treegrid2_beforehotrowadded")
            );
            
            append((new xui.UI.SButton())
            .setHost(host,"ctl_sbutton7")
            .setLeft(70)
            .setTop(260)
            .setWidth(90)
            .setCaption("Get Data")
            .onClick("_ctl_sbutton7_onclick")
            );
            
            return children;
            // ]]Code created by CrossUI RAD Tools
        },
        // To determine whether to add this row or not
        _ctl_treegrid2_beforehotrowadded:function (profile, row, leaveGrid){
            if(_.get(row,["cells","0","value","length"])){
                return true;
            }else{
                return false;
            }
        },
        _ctl_sbutton7_onclick:function (profile, e, src, value){
            var ns = this,
                data = ns.ctl_treegrid2.getRows("min");
            xui.echo(data);
        }
    }
});
   

tomy300
Posts: 70
Joined: Sat Nov 09, 2013 12:27 am

Re: treegrid hotrow

Post by tomy300 »

thanks it's working :)

tomy300
Posts: 70
Joined: Sat Nov 09, 2013 12:27 am

Re: treegrid hotrow

Post by tomy300 »

Hi again

I try to hotrow on keyup return and add this row instead of click somewhere to make the hotrow add it , my code does't seem to work.


I just want to add a new line when I keypress "return"

Code: Select all

        _ctl_treegrid2_onhotkeyup:function (profile,keyboard,e,src){
            var ns = this, uictrl = profile.boxing();
    
            if(keyboard == "enter,,,"){
              row = ns.ctl_treegrid2.getActiveRow();  
              ns.ctl_treegrid2.setActiveRow(row.id);

            }
            
        }


support
Posts: 356
Joined: Sat Apr 27, 2013 9:22 am

Re: treegrid hotrow

Post by support »

You should learn to debug your code.
Monitor the "keyboard" please.

Post Reply