:: Forum >>
async and getRowProperty("count")
I have this bit of code -
<script>
var table1 = new Active.Text.Table
var obj1 = new Active.Controls.Grid
var columns1 =
[
"User", "Spid", "Database", "Start Time", "Host",
"Program", "Command", "Blocked By", "Time Blocked"
]
table1.setURL("$URL1")
table1.request()
obj1.setId("tab1")
obj1.setColumnProperty("texts", columns1)
obj1.setDataModel(table1)
obj1.setStyle("height", "20%")
document.write(obj1)
</script>
And I can't seem to get the row count. It always comes back as zero ("0"). I suspect it may be to do with the async nature of the request method.
What I'm trying to do is set the height of the grid to a percentage of the maximum heigth I've set based on the number of rows.
I.e. if the grid displays 10 rows and I only have 5 to show, set the height of the grid to 50% so that the horizontal scrollbar is just below the data rather than after the rows and some empty space.
Anthony M.
Monday, August 1, 2005
OK, for closure, I figured this out. The rowcount will always return 0 with the async method because the tables are populated after the page and its grids have begun rendering (i.e. after the document.write() call).
Since I'm using CGI and perl and I'm creating the input file for the setURL() method on Unix, I changed my logic to count the number of lines in the file instead.
The logic for that is just "wc -l filename | nawk '{print $1}'". I assign the result of this into a variable in perl. And then apply the following logic -
$size = 214;
if ($val < 9)
{
$size = 36 + (18 * (($val < 1) ? 1 : $val));
}
Where $size is the absolute size of the grids in pixels and $val is the result of the wordcount. I'm displaying 10 lines plus the header and a horizontal scollbar (or 11 lines if no horizontal scollbar). That is, a total of 12 rows.
I then call setStyle like this -
obj0.setStyle("height", "${size}px")
I repeat this code for each grid. It seems to work fine now.
Anthony M.
Wednesday, August 3, 2005
This topic is archived.
Back to support forum
Forum search