{"hidden":false,"children":[{"configs":{"itemId":"module"},"expanded":true,"children":[{"configs":{"layout":"fit","itemId":"viewport1"},"expanded":true,"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}","itemId":"grid1","editable":"true","loadColumns":"none","multiSelect":"true"},"expanded":true,"children":[{"configs":{"itemId":"store","autoLoad":"true","url":"m?xwl=examples/crud/crud-db-access/select"},"expanded":false,"children":[],"type":"store","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}"}},{"configs":{"itemId":"tbar"},"expanded":true,"children":[{"configs":{"itemId":"newBtn","tooltip":"添加新的记录","text":"添加","iconCls":"record_add_icon"},"expanded":false,"children":[],"type":"item","events":{"click":"Wb.addEdit(app.grid1); //更多选项可使用Wb.add方法"}},{"configs":{"itemId":"delBtn","tooltip":"删除选择的记录","text":"删除","iconCls":"record_delete_icon"},"expanded":false,"children":[],"type":"item","events":{"click":"Wb.remove(app.grid1);"}},{"configs":{"itemId":"item1","text":"-"},"expanded":false,"children":[],"type":"item"},{"configs":{"itemId":"saveBtn","tooltip":"保存所有的更改","text":"保存","iconCls":"save_icon"},"expanded":false,"children":[],"type":"item","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});"}}],"type":"toolbar"}],"type":"grid"}],"type":"viewport"}],"type":"module"}],"roles":{"demo":1},"title":"字典定制列可编辑表格","iconCls":"","inframe":false,"pageLink":""}