Grid (Table) with cell format and XML data set : Table Grid : GUI Components JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » GUI Components » Table Grid »

 

Grid (Table) with cell format and XML data set



<html>
<head>
  <title>ActiveWidgets Grid :: Examples</title>
  <style> body, html {margin:0px; padding: 0px; overflow: hidden;</style>

  <!-- ActiveWidgets stylesheet and scripts -->
  <link href="gridRuntime/styles/classic/grid.css" rel="stylesheet" type="text/css" ></link>
  <script src="gridRuntime/lib/grid.js"></script>

  <!-- grid format -->
  <style>
    .active-controls-grid {height: 100%; font: menu;}

    .active-column-{width:  80px;}
    .active-column-{width: 200px; background-color: threedlightshadow;}
    .active-column-{text-align: right;}
    .active-column-{text-align: right;}
    .active-column-{text-align: right;}
    .active-column-{text-align: right;}

    .active-grid-column {border-right: 1px solid threedshadow;}
    .active-grid-row {border-bottom: 1px solid threedlightshadow;}
  </style>
</head>
<body>
  <script>

  //  create data formats
  var string = new Active.Formats.String;
  var number1 = new Active.Formats.Number;
  var number2 = new Active.Formats.Number;
  var date = new Active.Formats.Date;

  //  define formatting rule for text output
  number1.setTextFormat("#,###.##");
  number2.setTextFormat("");

  date.setTextFormat("dd mmm yy");
  date.setDataFormat("ISO8061");

  //  create ActiveWidgets data model - XML-based table
  var table = new Active.XML.Table;

  //  provide data URL
  table.setURL("gridExamples/data/companies-dataset.xml");

  //  set rows XPath
  table.setRows("//NewDataSet/*");

  //  set columns XPath
  table.setColumns(["ticker""name""mktcap""sales""employees""timestamp"]);

  //  set column formatting
  table.setFormats([string, string, number1, number1, number2, date]);

  //  start asyncronous data retrieval
  table.request();

  //  define column labels
  var columns = ["Ticker""Company Name""Market Cap.""$ Sales""Employees""Date"];

  //  create ActiveWidgets Grid javascript object
  var obj = new Active.Controls.Grid;

  //  provide column labels
  obj.setColumnProperty("texts", columns);

  //  provide external model as a grid data source
  obj.setDataModel(table);

  //  write grid html to the page
  document.write(obj);

  </script>
</body>
</html>

           
       

Download : Download nav_ActiveWidgets.zip nav_ActiveWidgets.zip


-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo GUI Components
» Table Grid