webgui/www/extras/assetManager/ActiveWidgets/documentation/tutorial/grid/style-alternate.htm
2004-12-17 05:38:46 +00:00

69 lines
2.1 KiB
HTML
Executable file

<html>
<head>
<title>ActiveWidgets :: DHTML Grid :: Using alternate colors for grid rows.</title>
<link href="../../../common/site.css" type="text/css" rel="stylesheet" />
<script src="../../../common/site.js"></script>
</head>
<body class="tutorial">
<script>document.write(window.$header)</script>
<div class="image-home">
</div>
<div class="location">:: Documentation &gt;&gt; Tutorial &gt;&gt; Grid &gt;&gt;
</div>
<h1>
Using alternate colors for grid rows.
</h1>
<p>
With a few steps you can enable alternate background colors on the grid.
</p>
<p>
The background color should be generated by the function depending on the
row order in the grid.
</p>
<pre>var alternate = function(){
return this.getProperty("row/order") % 2 ? "threedface" : "white";
}</pre>
<p>
Then you need to create a new row template.
</p>
<pre>var row = new Active.Templates.Row;</pre>
<p>
Assign a color function to the background color style.
</p>
<pre>row.setStyle("background", alternate);</pre>
<p>
An use this modified row template instead of standard one.
</p>
<pre>obj.setTemplate("row", row);</pre>
<p>
Complete example:
</p>
<textarea id="grid1" wrap="off" style="HEIGHT:280px" target="height:200px">
var obj = new Active.Controls.Grid;
obj.setProperty("column/count", 5);
obj.setProperty("row/count", 10);
obj.setProperty("data/text", "some text...");
var alternate = function(){
return this.getProperty("row/order") % 2 ? "threedface" : "white";
}
var row = new Active.Templates.Row;
row.setStyle("background", alternate);
obj.setTemplate("row", row);
document.write(obj);
</textarea>
<script>if(window.site) site.example("grid1");</script>
<p>
<a href="style.htm">Back to Visual Style</a>
</p>
<script>document.write(window.$column)</script>
<script>document.write(window.$tutorial)</script>
<script>document.write(window.$footer)</script>
</body>
</html>