3.2.0

set grid class

Is it possible to set a class to the grid? I have different grids, but I want to assign the same classnames to them without having to add every gridId to the css.
My grid's id: title
My className: myGrid

title.setClass("title","myGrid");
title.setGridClass("myGrid");

The code above does not work, does anyone have a solution for this?
RG
November 18,
You can use:
AW.object("id");

AW.object("title").setClass("classname","value");

value can also be a function , check:
http://www.activewidgets.com/aw.system.html/setclass.html
C++
November 18,
But maybe what you really need to apply "a few" styles for each grid is subclassing and add some properties:

Simple subclass:
http://www.activewidgets.com/javascript.forum.11859.1/how-to-extend-core-functionallity.html

Subclass adding property:
// create MyGrid class
var MyGrid = AW.UI.Grid.subclass();

// modify MyGrid prototype
MyGrid.create = function(){
    var obj = this.prototype;
    obj.defineControlProperty('cellscolor', 'red');
    obj.setStyle("background", function(){return this.getControlCellscolor()}); 
    obj.setHeaderText(["Col1", "Col2", "Col3"]);
    obj.setColumnCount(3);
}

// create an object (instance of MyGrid class)
var obj = new MyGrid;
obj.setControlCellscolor('yellow');
obj.setCellText("text");
obj.setRowCount(10);
document.write(obj); 

 var obj2 = new MyGrid;
obj2.setControlCellscolor('green');
obj2.setCellText("text");
obj2.setRowCount(10);
document.write(obj2);
C++
November 18,
Thanks for your answers, but what I want is different. I have 4 grids in one page. In other pages I have only one grid which class will be set through #myGrid.
But the 4 grids in one page have different id's. What setClass does is:

Calling setClass(name, value) will assign the CSS class aw-name-value which can be referred in stylesheet via

.aw-name-value {
    ...
}


I want to assign a overall class (instead of #myGrid -> .myGrid) to the grids. Is that also possible?
RG
November 19,
It should, although I never tried that, ( not much proficient in css sorry :) )
just be sure to asign the new class to the right Template. ( i.e full-object/rows/cells/heathers etc)

http://www.activewidgets.com/javascript.forum.11546.5/firefox-aw-alternate-with-aw.html
November 19,
i.e
obj.setClass('name'.'value');
obj.getRowsTemplate().setClass('name'.'value');
obj.getHeadersTemplate().setClass('name'.'value');
obj.getCellTemplate().setClass('name'.'value');
with:
.aw-name-value { css ...}



November 19,

This topic is archived.

See also:


Back to support forum