Composite controls - adding more elements to the grid

It is often necessary to add more elements to the grid, like action toolbar on top of the headers or paging controls in the bottom. The grid has Layout template defined but not used by default - it simply calls the next one (scrolling). However the Layout template can be used to split the control area (for example, with AW.Panels.Horizontal), put the grid in the middle and additional elements into the top/bottom areas.

var obj = new AW.UI.Grid;
    obj.setSize(800, 250);
    obj.setCellText(function(i, j){return j + "-" + i});


    obj.defineTemplate("topLine", function(){return "top"});
    obj.defineTemplate("bottomLine", function(){return "bottom"});

    obj.setLayoutTemplate(new AW.Panels.Horizontal);
            case 0: return this.getTopLineTemplate();
            case 1: return this.getScrollTemplate();
            case 2: return this.getBottomLineTemplate();

    obj.setPanelHeight(30, 0); //top line
    obj.setPanelHeight(20, 2); //bottom line

Alex (ActiveWidgets)
March 3,
This is very good to know. I have a use for it already!
Jim Hunter (www.FriendsOfAW.com)
March 3,
I often wondered what the purpose of the Layout template was - as you say it simply calls the Scroll Template !

Great Tip Alex.
March 4,

This topic is archived.

See also:

Back to support forum