ЛУЧШИЙ САЙТ ДЛЯ ВЕБ-РАЗРАБОТЧИКОВ
AppML. Уроки для начинающих

AppML кейс - Клиенты


HTML страница

Это HTML ресурс:

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="../w3css/4/w3.css">
<script src="2.0.3/appml.js"></script>
</head>
<body>

<div class="w3-container w3-content">
<h1>Клиенты</h1>

<div class="w3-container w3-light-grey w3-padding-large w3-margin-bottom" appml-data="https://www.w3schools.com/appml/appml.php?model=model_customersform" appml-controller="myFormController" id="Form01" style="display:none;">
  <div appml-include-html="inc_formcommands.html"></div>
  <p>
    <label>CustomerName:</label>
    <input id="customername" class="w3-input w3-border">
  </p>
  <p>
    <label>ContactName:</label>
    <input id="contactname" class="w3-input w3-border">
  </p>
  <p>
    <label>Address:</label>
    <input id="address" class="w3-input w3-border">
  </p>
  <p>
    <label>City:</label>
    <input id="city" class="w3-input w3-border">
  </p>
  <p>
    <label>PostalCode:</label>
    <input id="postalcode" class="w3-input w3-border">
  </p>
  <p>
    <label>Country:</label>
    <input id="country" class="w3-input w3-border">
  </p>
</div>

<div appml-data="https://www.w3schools.com/appml/appml.php?model=model_customerslist">
  <div appml-include-html="inc_listcommands.html"></div>
  <div appml-include-html="inc_filter.html"></div>
  <table class="w3-table-all">
    <tr>
      <th></th>
      <th>Клиент</th>
      <th>Город</th>
      <th>Страна</th>
    </tr>
    <tr appml-repeat="records">
      <td style="cursor:pointer;width:40px;" onclick="appml('Form01').run({{CustomerID}});">&#9998;</td>
      <td>{{CustomerName}}</td>
      <td>{{City}}</td>
      <td>{{Country}}</td>
    </tr>
  </table>
</div>

</div>

<script>
function myFormController($appml) {
  if ($appml.message == "ready") {return -1; }
  if ($appml.message == "loaded") {
    document.getElementById("Form01").style.display = "";
  }
}
</script>

</body>
</html>
PHP »   .NET »

Модели

Это модели, используемые в приложении:

Модель списка

{
"rowsperpage" : 10,
"database" : {
"connection" : "localmysql",
"sql" : "SELECT * FROM Customers",
"orderby" : "CustomerName"
},
"filteritems" : [
{"item" : "CustomerName", "label" : "Customer"},
{"item" : "City"},
{"item" : "Country"}
],
"sortitems" : [
{"item" : "CustomerName", "label" : "Customer"},
{"item" : "City"},
{"item" : "Country"}
]
}

Модель формы

{
"database" : {
"connection" : "localmysql",
"maintable" : "Customers",
"keyfield" : "CustomerID",
"sql" : "SELECT * FROM Customers"
},
"updateItems" : [
{"item" : "CustomerName"},
{"item" : "Address"},
{"item" : "PostalCode"},
{"item" : "City"},
{"item" : "Country"}
]
}