π AppML β How to Create Lists: Display Dynamic Data Without JavaScript
π§² Introduction β Why Use AppML to Create Lists?
When building dynamic websites or dashboards, displaying a list of itemsβlike users, products, or tasksβis essential. With AppML, you can create lists directly in HTML and bind them to JSON, XML, or database data without writing any JavaScript.
π― In this guide, youβll learn:
- How to create dynamic lists using
appml-data - How to connect to different data formats (JSON, XML, server)
- How to loop and render content using
{{}}syntax - How to filter, sort, and style lists dynamically
π§ What Is a List in AppML?
In AppML, a list is any repeating HTML block (like <li> or <p>) inside a container that has an appml-data attribute. AppML uses this attribute to load data and repeat the content for each item.
<div appml-data="data.json">
<p>{{name}} β {{email}}</p>
</div>
AppML replaces {{name}} and {{email}} with data from each record.
π§ͺ Example 1 β Display List from JSON File
β
users.json
[
{ "name": "Alice", "email": "alice@example.com" },
{ "name": "Bob", "email": "bob@example.com" }
]
β HTML List
<div appml-data="users.json">
<p>{{name}} β {{email}}</p>
</div>
π AppML repeats the <p> element for each user, binding {{name}} and {{email}}.
π§ͺ Example 2 β List with <ul> and <li>
<div appml-data="data/tasks.json">
<ul>
<li>{{title}} β Status: {{status}}</li>
</ul>
</div>
β
Sample tasks.json
[
{ "title": "Design Landing Page", "status": "In Progress" },
{ "title": "Test User Flow", "status": "Completed" }
]
βοΈ The list will auto-render with all task titles and statuses.
π§ͺ Example 3 β Bind List from PHP (MySQL)
β
PHP Endpoint: employees.php
<?php
include("appml.php");
$appml = new AppML();
$appml->model = "models/employees-model.json";
$appml->run();
?>
β HTML List
<div
appml-data="employees.php"
appml-model="models/employees-model.json"
appml-message>
<h2>Employee List</h2>
<p>{{name}} β {{department}}</p>
</div>
β
JSON Model: employees-model.json
{
"key": "id",
"table": "employees",
"fields": [
{ "name": "name", "required": true },
{ "name": "department" }
]
}
π How AppML Processes Lists
- Loads the data source specified by
appml-data. - Searches for a repeating block inside the container (like
<p>or<li>). - For each record, clones the block and replaces
{{field}}with actual values. - Renders the final HTML on the page.
π οΈ Filter and Sort Lists
AppML supports client-side filtering with custom JS:
<input oninput="myAppML.filter='name.includes('+this.value+')'">
For sorting, use orderby in your model:
"orderby": "name"
Or sort manually via controller functions.
π¨ Styling Dynamic Lists
| Technique | Use Case |
|---|---|
| Tailwind or Bootstrap | Easily style list layout and spacing |
AppML rows in <div>s | Great for card or grid designs |
| Conditional icons | Add status symbols using data binding |
Use appml-message | Show errors or status messages |
π Summary β Recap & Key Takeaways
Creating dynamic lists in AppML is as easy as writing standard HTML. You just plug in your data using appml-data and wrap the display in repeatable tags. No JavaScript, loops, or DOM handling required!
π Key Takeaways:
- Use
appml-datato connect to JSON, XML, or PHP endpoints - Write
{{field}}placeholders to bind data into HTML - Works with
<p>,<li>,<div>, and table rows - Supports filtering, styling, and model-based validation
- Perfect for product lists, task lists, staff directories, and more
βοΈ AppML lists are lightweight, clean, and ideal for building responsive frontends with real-time content.
β FAQs β Creating Lists in AppML
β Can I nest lists in AppML (e.g., categories with sub-items)?
β οΈ AppML does not natively support nested loops. Flatten your data or use custom controller logic.
β Can I bind lists to XML data?
β
Yes. AppML supports XML files, as long as the structure is consistent and array-like.
β Can I display images in lists with AppML?
β
Yes. Use <img src="{{image_url}}"> inside your list item.
β How many records can AppML list before it lags?
β
AppML handles 100β500 records well. Use pagination ("rows": 20 in model) for larger datasets.
β Can I make lists editable using AppML?
β
Yes. Add <input appml-field="name"> to each item and enable model-based update support.
Share Now :
