{"title":"字典定制列可编辑表格","inframe":false,"hidden":false,"roles":{"demo":1,"dev":1},"pageLink":"","children":[{"configs":{"itemId":"module"},"children":[{"configs":{"layout":"fit","itemId":"viewport1"},"children":[{"configs":{"tagConfigs":"{\n  //如果表格存在此方法，二进制字段自动生成下载链接并指向此方法，如果存在多个二进制字段可通过ifDownloadBlob方法控制哪个字段提供下载\n  downloadBlob: function(fieldName, rowIndex) {\n    var grid = this;\n    //在文件列表中按ctrl+双击文件名可添加url地址\n    Wb.download('m?xwl=examples/crud/crud-db-access/download-blob', {\n      ID_FIELD: grid.store.getAt(rowIndex).data.ID_FIELD\n    });\n  },\n  /*ifDownloadBlob:function(fieldName){\n     return fieldName=='foo';//只允许foo字段下载\n  }其他还有方法ifUploadBlob，ifRemoveBlob控制是否提供该项功能*/\n  uploadBlob: function(fieldName, rowIndex) {\n    var grid = this,\n      rec = grid.store.getAt(rowIndex);\n    if (rec.dirty) {\n      Wb.warn('请保存该记录然后再试一次。');\n      return;\n    }\n    Wb.run({\n      url: 'upload', //调用upload公用对话框，无需权限。\n      success: function(app) {\n        app.upload({\n          url: 'm?xwl=examples/crud/crud-db-access/upload-blob',\n          title: '上传二进制字段',\n          params: rec.data, //整条记录所有字段都作为参数\n          success: function() {\n            rec.set(fieldName, 'blob'); //表示有二进制内容\n            rec.commit();\n          }\n        });\n      }\n    });\n  },\n  removeBlob: function(fieldName, rowIndex) {\n    var grid = this,\n      rec = grid.store.getAt(rowIndex);\n    if (rec.dirty) {\n      Wb.warn('请保存该记录然后再试一次。');\n      return;\n    }\n    Wb.confirm('确定要删除该记录字段 \u201c' + Wb.getColumn(grid, fieldName).text + '\u201d 的内容吗？', function() {\n      Wb.request({\n        url: 'm?xwl=examples/crud/crud-db-access/remove-blob',\n        params: rec.data,\n        success: function(resp) {\n          rec.set(fieldName, ''); //表示无二进制内容\n          rec.commit();\n        }\n      });\n    });\n  }\n}","multiSelect":"true","itemId":"grid1","editable":"true","loadColumns":"none"},"children":[{"configs":{"autoLoad":"true","itemId":"store","url":"m?xwl=examples/crud/crud-db-access/select"},"events":{"success":"//基于字典生成的列基础上的自定义\nif (Wb.isEmpty(app.grid1.columns)) {\n  var cols = Wb.getColumns(store),\n    numCols = cols.splice(3, 2);\n  cols.splice(3, 0, {\n    text: '数字列',\n    items: numCols\n  });\n  app.grid1.reconfigure(null, cols);\n}"},"children":[],"type":"store","expanded":false},{"configs":{"itemId":"tbar"},"children":[{"configs":{"text":"添加","itemId":"newBtn","iconCls":"record_add_icon","tooltip":"添加新的记录"},"events":{"click":"Wb.addEdit(app.grid1); //更多选项可使用Wb.add方法"},"children":[],"type":"item","expanded":false},{"configs":{"text":"删除","itemId":"delBtn","iconCls":"record_delete_icon","tooltip":"删除选择的记录"},"events":{"click":"Wb.remove(app.grid1);"},"children":[],"type":"item","expanded":false},{"configs":{"text":"-","itemId":"item1"},"children":[],"type":"item","expanded":false},{"configs":{"text":"保存","itemId":"saveBtn","iconCls":"save_icon","tooltip":"保存所有的更改"},"events":{"click":"if (!Wb.verifyGrid(app.grid1)) //验证数据是否合法\n  return;\nWb.sync({\n  grid: app.grid1,\n  url: 'm?xwl=examples/crud/crud-db-access/save',\n  message: '正在保存中...',\n  success: function(resp) {\n    //ID_FIELD值在后台生成，把返回的ID_FIELD值列表同步到表格中\n    Wb.syncCreate(app.grid1, Wb.decode(resp.responseText));\n  }\n});"},"children":[],"type":"item","expanded":false}],"type":"toolbar","expanded":true}],"type":"grid","expanded":true}],"type":"viewport","expanded":true}],"type":"module","expanded":true}],"iconCls":""}