数据表格h函数change调用数据源方法

[复制链接]
查看: 928   回复: 4     已解决

9

主题

6

回帖

2万

积分

论坛元老

Rank: 8Rank: 8

积分
21391
2023-5-24 13:12:25   显示全部楼层   阅读模式  
表格列的 render函数 代码如下


let {row, column} = params
let cellValue = row[column.prop] || ''
if(row.index == 1){
  return cellValue
}else{
  return h(components.ElCheckboxGroup, {
        modelValue: cellValue,
        onChange: (val) => {
          row[column.prop] = val
          //   this.getFormRef().getTopFormRef().executeDataSource('修改排班情况',val).then(res =>{})
        }
      }, [
        h(components.ElCheckbox, {label: '白班'}),
        h(components.ElCheckbox, {label: '加强班'}),
        h(components.ElCheckbox, {label: '晚班'}),
])
}
目的是 修改checkbox框时候 实时去更新数据 报错 报this.getFormRef is not a function


admin已获得悬赏 500 威望

最佳答案

这行错了: this.getFormRef().getTopFormRef().executeDataSource('修改排班情况',val) 按下面改: let {row, column, dataTableRef} = params //注意这行 let cellValue = row[column.prop] || '' let formRef = ...
回复

使用道具 举报

7

主题

237

回帖

24万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
244099
2023-5-24 13:18:16   显示全部楼层  
这行错了:
this.getFormRef().getTopFormRef().executeDataSource('修改排班情况',val)

按下面改:
let {row, column, dataTableRef} = params  //注意这行
let cellValue = row[column.prop] || ''
let formRef = dataTableRef.getFormRef()  //注意这行
if(row.index == 1){
  return cellValue
}else{
  return h(components.ElCheckboxGroup, {
        modelValue: cellValue,
        onChange: (val) => {
          row[column.prop] = val
          //   formRef.getFormRef().getTopFormRef().executeDataSource('修改排班情况',val).then(res =>{})
        }
      }, [
        h(components.ElCheckbox, {label: '白班'}),
        h(components.ElCheckbox, {label: '加强班'}),
        h(components.ElCheckbox, {label: '晚班'}),
])
}
回复

使用道具 举报

9

主题

6

回帖

2万

积分

论坛元老

Rank: 8Rank: 8

积分
21391
nihaoweixiao (楼主)
2023-5-24 13:20:02   显示全部楼层  
admin 发表于 2023-5-24 13:18
这行错了:
this.getFormRef().getTopFormRef().executeDataSource('修改排班情况',val)

formRef is not defined
回复

使用道具 举报

9

主题

6

回帖

2万

积分

论坛元老

Rank: 8Rank: 8

积分
21391
nihaoweixiao (楼主)
2023-5-24 13:21:04   显示全部楼层  

请忽略此回复,请忽略此回复
回复

使用道具 举报

0

主题

3

回帖

3

积分

新手上路

Rank: 1

积分
3
2023-7-28 15:28:01   显示全部楼层  
请忽略此回复,请忽略此回复
回复

使用道具 举报

您需要登录后才可以回帖   登录 注册账号

高级模式