75 lines
2.2 KiB
HTML
Executable file
75 lines
2.2 KiB
HTML
Executable file
<html>
|
|
<head>
|
|
<title>ActiveWidgets Tutorial</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 >> Tutorial >> Grid >>
|
|
</div>
|
|
<h1>
|
|
Loading data from a text file.
|
|
</h1>
|
|
<p>
|
|
When the data is available in a plain text file (tabs or comma-delimited)
|
|
you can load it into the grid without any server-side processing at all.
|
|
</p>
|
|
<p>
|
|
The file may look like this:
|
|
</p>
|
|
<iframe src="companies.txt" style="HEIGHT:200px"></iframe>
|
|
|
|
<p>
|
|
The first step is to create an external data model object,
|
|
which will load the data and provide a necessary interface
|
|
for the grid to access it.
|
|
</p>
|
|
<pre>var table = new Active.Text.Table;</pre>
|
|
<p>
|
|
The data model should know the URL of the file.
|
|
</p>
|
|
<pre>table.setProperty("URL", "companies.txt");</pre>
|
|
<p>
|
|
And you should ask the model to start loading the file.
|
|
</p>
|
|
<pre>table.request();</pre>
|
|
<p>
|
|
After the grid object is created
|
|
</p>
|
|
<pre>var obj = new Active.Controls.Grid;
|
|
obj.setProperty("column/count", 5);</pre>
|
|
<p>
|
|
it is assigned our new external data model.
|
|
</p>
|
|
<pre>obj.setModel("data", table);</pre>
|
|
|
|
<p>
|
|
Don't forget to write the grid HTML to the page as usual.
|
|
</p>
|
|
<pre>document.write(obj);</pre>
|
|
|
|
<p>
|
|
Full script:
|
|
</p>
|
|
<textarea id="grid1" wrap="off" style="HEIGHT:200px" target="height:300px">
|
|
|
|
var table = new Active.Text.Table;
|
|
table.setProperty("URL", "companies.txt");
|
|
table.request();
|
|
|
|
var obj = new Active.Controls.Grid;
|
|
obj.setProperty("column/count", 5);
|
|
obj.setModel("data", table);
|
|
|
|
document.write(obj);
|
|
|
|
</textarea>
|
|
<script>if(window.site) site.example("grid1");</script>
|
|
<script>document.write(window.$column)</script>
|
|
<script>document.write(window.$tutorial)</script>
|
|
<script>document.write(window.$footer)</script>
|
|
</body>
|
|
</html>
|