1. 程式人生 > >(札記)EasyUI Form表單

(札記)EasyUI Form表單


1、easyui跟extjs一樣。form表單繫結資料的時候,一繫結時間格式的資料,其它資料就繫結不上了
2、easyui在form表單繫結資料時,不能繫結類名,即不能使用.來連線
可以這樣繫結資料:
$("#ff").form("load", {
  "testCm.id":row.id,
  "testCm.cphm":row.cphm,
  "testCm.cpys":row.cpys,
  "testCm.csys":row.csys,
  "testCm.passtime":new Date(value).toLocaleDateString();
  "testCm.ckFlag":row.ckFlag
});
表單的資料提交:
$('#ff').form('submit', {
  url:"testCm!saveTest.action",
  onSubmit: function(){
    //return $(this).form("validate");
  },
  success:function(data){
      $.messager.alert("提示資訊", "操作成功");
      $("#win").dialog("close");
      $("#datagrid").datagrid("load");
  }
});

Form表單的建立:
注:name 的值要匹配struts2的格式,否則提交會失敗。
<form id="ff" method="post">
  <div style="padding:5px;">
    <label for="passtime" style="width:80px;text-align:right;float:left;">passtime:</label>
    <input class="easyui-datetimebox" type="text" name="testCm.passtime" style="width:120px;" data-options="required:true" />
  </div>
  <div style="padding:5px;">
    <label for="cphm" style="width:80px;text-align:right;float:left;">cphm:</label>
    <input class="easyui-validatebox" type="text" name="testCm.cphm" style="width:120px;" data-options="required:true" />
  </div>
  <div style="padding:5px;">
    <label for="cpys" style="width:80px;text-align:right;float:left;">cpys:</label>
    <input class="easyui-validatebox" type="text" name="testCm.cpys" style="width:120px;" data-options="required:true" />
  </div>
  <div style="padding:5px;">
    <label for="csys" style="width:80px;text-align:right;float:left;">csys:</label>
    <input class="easyui-validatebox" type="text" name="testCm.csys" style="width:120px;" data-options="required:true" />
  </div>
  <div style="padding:5px;">
    <label for="ckFlag" style="width:80px;text-align:right;float:left;">ckFlag:</label>
    <select id="cc" class="easyui-combobox" name="testCm.ckFlag" style="width:120px;" data-options="required:true">
      <option>true</option>
      <option>false</option>
    </select>
  </div>
</form>