AppML - Using Text
AppML application can read data using a text file. Following is an example.
Step 1: Create Data
The first step is to create a csv based data file which will provide records to be displayed in application UI. Create a students-records.txt
students_records.txtRamesh,12,White, Suresh,12,Red, Mohan,12,Red, Robert,12,Red, Julie,12,White, Ali,12,White, Harjeet,12,White,
Step 2: Create Model
Create student_model.js file which will act as model to describe record.
{
"rowsperpage" : 7,
"data" : {
"type" : "csvfile",
"filename" : "students_records.txt",
"items" : [
{"name" : "studentName", "index" : 1},
{"name" : "class", "index" : 2},
{"name" : "section", "index" : 3}
]
}
}
student_application.html
<!DOCTYPE html>
<html lang="en-US">
<title>Students</title>
<style>
table {
border-collapse: collapse;
width: 100%;
}
th, td {
text-align: left;
padding: 8px;
}
tr:nth-child(even) {background-color: #f2f2f2;}
</style>
<script src="https://www.w3schools.com/appml/2.0.3/appml.js"></script>
<body>
<table appml-data="appml.php?model=students_model">
<tr>
<th>Student</th>
<th>Class</th>
<th>Section</th>
</tr>
<tr appml-repeat="records">
<td>{{studentName}}</td>
<td>{{class}}</td>
<td>{{section}}</td>
</tr>
</table>
</body>
</html>
Output
Deploy the application on Web Server and access the html page. Verify the output.
appml_data.htm
Advertisements