- 注册时间
- 2013-4-7
- 最后登录
- 2018-10-15
- 阅读权限
- 10
- 积分
- 205
- 精华
- 0
- 帖子
- 46
|
本帖最后由 天狼 于 2014-2-8 16:02 编辑
关于DataGrid编辑行验证的问题官方给出的例子:http://www.miniui.com/demo/datagrid/cellvalidation.html
没有任何问题。
不知何故,我的代码始终无法验证通过,直接贴代码吧!
html代码:
<div id="dgExpenseDetail" class="mini-datagrid" style="width:100%;"
borderStyle="border:0px" idField="expenseDetailId"
allowResizeColumn="false" allowMoveColumn="false"
allowCellEdit="true" allowCellSelect="true" allowCellValid="true"
url="<s:url namespace="/expense" action="expenseDetailList" />"
sizeList="[1,2,3,4,5,6]" pageIndex="1" pageSize="6"
totalField="totalElements" dataField="pageList">
<div property="columns">
<div type="checkcolumn"></div>
<div field="categroy.categroyId" displayField="categroy.name" vtype="required" width="20%" align="center" headerAlign="center" >部门
<input property="editor" class="mini-combobox" style="width:100%;"
valueField="categroyId" textField="name"
url="<s:url namespace="/expense" action="categroyAll" />"/>
</div>
<div field="amount" width="20%" align="center" dataType="currency" currencyUnit="¥" headerAlign="center">项目金额
<input property="editor" class="mini-textbox" style="width:100%;"/>
</div>
<div field="description" width="45%">费用说明
<input property="editor" class="mini-textbox" style="width:100%;"/>
</div>
</div>
</div>
</div>js代码:
var grid = mini.get("dgExpenseDetail");
grid.load({expenseId:1});
其中<s:url namespace="/expense" action="expenseDetailList" />返回的JSON为:
{
"pageList":[
{"amount":2000.0,"categroy":{"categroyId":2,"name":"城际交通费"},"description":"222","expense":null,"expenseDetailId":1},
{"amount":1000.0,"categroy":{"categroyId":3,"name":"交际餐费"},"description":"111","expense":null,"expenseDetailId":2}
],
"totalElements":2
}
UI效果为:
当点击“增加”按钮执行代码为:
//添加
function addRow() {
var newRow = {};
grid.addRow(newRow, 0);
grid.validateRow(newRow);//加入新行,马上验证新行
}
效果为:
其中<s:url namespace="/expense" action="categroyAll" />返回的JSON为:
[
{"categroyId":3,"name":"交际餐费"},
{"categroyId":2,"name":"城际交通费"},
{"categroyId":1,"name":"市内交通费"},
{"categroyId":4,"name":"礼品费"}
]
任意选择一项后,单击“保存”按钮执行代码为:
//保存
function saveData() {
grid.validate();
mini.alert(grid.isValid());
}
问题来了,现在部门下拉列表无论是否选择,点击“保存”按钮,始终弹出false,何解啊?
|
|