表格的数据验证功能是否能够增强一下,现在检查一下字段值为空都要写这么一大段代码,实在是瘦不了啊:- function isValid() {
- var grid1 = F('<%= Grid1.ClientID %>');
- var valid = true, modifiedData = grid1.getModifiedData();
-
- $.each(modifiedData, function (index, rowData) {
-
- // rowData.id: 行ID
- // rowData.status: 行状态(newadded, modified, deleted)
- // rowData.values: 行中修改单元格对象,比如 { "Name": "刘国2", "Gender": 0, "EntranceYear": 2003 }
- if (rowData.status === 'deleted') {
- return true; // continue
- }
-
- var name = rowData.values['Name'];
- // 更改了姓名列,并且为空字符串
- if (typeof (name) != 'undefined' && $.trim(name) == '') {
- F.alert({
- message: '姓名不能为空!',
- ok: function () {
- grid1.startEdit(rowData.id, 'Name');
- }
- });
-
- valid = false;
-
- return false; // break
- }
- });
-
-
- return valid;
- }
复制代码
|