<div appml-include-html="inc_header.htm"></div>
<h1>Customers</h1>
<table appml-data="customers.js" appml-controller="myController">
<tr>
<th>Customer</th>
<th>City</th>
<th>Country</th>
</tr>
<tr appml-repeat="records">
<td>{{CustomerName}}</td>
<td>{{City}}</td>
<td>{{Country}}</td>
</tr>
</table>
<div appml-include-html="inc_footer.htm"></div>
亲自试一试»
Attribute | Description | Explained |
---|---|---|
appml-controller | Defines an AppML controller | AppML Controllers |
appml-data | Defines the data source for an application | AppML Data |
appml-include-html | Defines HTML to be included | AppML Includes |
appml-repeat | Defines an HTML element to be repeated | AppML Howto |
function myController($appml) {
if ($appml.message == "display") {
if ($appml.display.name == "CustomerName") {
$appml.display.value = $appml.display.value.toUpperCase();
}
}
}
亲自试一试»
Message | Sent |
---|---|
ready | After AppML is initiated, and ready to load data. |
loaded | After AppML is fully loaded, ready to display data. |
display | Before AppML displays a data item. |
done | After AppML is done (finished displaying). |
submit | Before AppML submits data. |
error | After AppML has encountered an error. |
AppML 消息在有关章节中进行了解释AppML消息。
{
"security": "admin",
"rowsperpage" : 10,
"database": {
"connection": "mysql",
"sql" : "SELECT * FROM Customers",
"orderby" : "CustomerName"}},
"filteritems" : [
{"item" : "CustomerName", "label" : "Customer"},
{"item" : "City"},
{"item" : "Country"}],
"sortitems" : [
{"item" : "CustomerName", "label" : "Customer"},
{"item" : "City"},
{"item" : "Country"}]
}
Element | Description |
---|---|
"data" | Defines a flat file source for the model |
"database" | Defines a database source for the model |
"filteritems" | Defines filter restrictions |
"rowsperpage" | Defines number of rows to be fetched per page |
"security" | Defines the security for the model |
"sortitems" | Defines sorting restrictions |
您必须以 "admin" 组成员的身份登录才能访问此应用程序:
{
"security": "admin",
"database": {
"connection": "mysql",
"sql" : "SELECT * FROM Customers",
"orderby" : "CustomerName"}
}
您可以将自己的私有数据添加到模型中。
此示例建议对数据进行限制:
"restrictions" : {
"fname" : {"maxlength": 40},
"price" : {"max": 999,"min": 100}
}
模型数据可由服务器应用程序和 AppML 控制器使用。
此示例使用模型数据来验证输入:
function myController($appml) {
if ($appml.message == "submit") {
var price = document.getElementById("price").value;
if (price < $appml.model.restrictions.price.min) {
$appml.displayError(15, "Price too low!");
return;
}
}