Please explain the code to a newbie <script>if(window.site) site.example("grid2");</script>

Hi team,

throughout the samples, site.example is used to output the grid object. Why is the example function used. Can i use document.write instead and what is the advantage of using the site.example() function ? What function i am supposed to use in order to display a grid within the middle of a webpage surrounded by other html tags ?

Thanks a lot

November 27,
Place the grid within a div to have it in the middle of a site:

<DIV id="mydatagriddiv" style="width:700px;height:200px;">
try {
  var mydatagrid = new Active.Controls.Grid;
  mydatagrid.gridData =  [ 
            ["MSFT","Microsoft Corporation", "314,571.156", "32,187.000", "http://www.microsoft.com", "06/06/2004", "One"],
            ["VRTS", "Veritas Software Corp.", "14,444.272", "1,578.658", "http://www.veritas.com", "06/06/2004", "One"],
            ["SYMC", "Symantec Corporation", "9,932.483", "1,482.029", "http://www.symantec.com", "06/06/2004", "One"],
            ["INFY", "Infosys Technologies Ltd.", "9,763.851", "830.748", "http://www.infosys.com", "06/06/2004", "One"],

var mydatagrid_columns = [ "Ticker", "Company Name", "Market Cap.", "$ Sales", "Website", "Date", "Select" ]; 
  mydatagrid.getDataText = function(i, j){return mydatagrid.gridData[i][j]};
  mydatagrid.setDataText = function(value, i, j){mydatagrid.gridData[i][j] = value};
  mydatagrid.setColumnText(function(i){return mydatagrid_columns[i]});
catch (error){

Frank :-)
November 27,
You can also look in the examples directory:

/examples/grid/two grids on one page.htm

You can use both document.write(obj) and element.innerHTML = obj to add the grid to your page.
Alex (ActiveWidgets)
November 28,

This topic is archived.

See also:

Back to support forum