:: Documentation >> Tutorial >> Grid >>

Loading data from a text file.

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.

The file may look like this:

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.

var table = new Active.Text.Table;

The data model should know the URL of the file.

table.setProperty("URL", "companies.txt");

And you should ask the model to start loading the file.

table.request();

After the grid object is created

var obj = new Active.Controls.Grid;
obj.setProperty("column/count", 5);

it is assigned our new external data model.

obj.setModel("data", table);

Don't forget to write the grid HTML to the page as usual.

document.write(obj);

Full script: