{"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":"statusCombo","keyName":"status"},"expanded":false,"children":[],"type":"combo"},{"configs":{"itemId":"store","autoLoad":"true","url":"m?xwl=examples/crud/crud-db-access/select"},"expanded":false,"children":[],"type":"store","events":{"load":"//设置grid属性loadColumn为none表示不自动加载列，改用Wb.loadColumn使用代码方式加载列\nif (!store.colsLoaded) {\n  //重定义BOOL_FIELD使用check column\n  var col = Wb.getColumn(store, 'BOOL_FIELD');\n  delete col.renderer;\n  delete col.editor;\n  Wb.apply(col, {\n    xtype: 'checkcolumn',\n    exportText: '使用Check',\n    text: '<b>使用Check<\/b>'\n  });\n  //绑定INT_FIELD为键值\n  col = Wb.getColumn(store, 'INT_FIELD');\n  Wb.apply(col, {\n    editor: app.grid1.statusCombo,\n    exportText: '绑定键值',\n    renderer: Wb.kvRenderer, //键值显示器\n    keyItems: app.grid1.statusCombo.store.data, //键值对照项数据\n    text: '<b>绑定键值<\/b>'\n  });\n  //通过代码方式加载列\n  Wb.loadColumns(store);\n  store.colsLoaded = true;\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":""}