当实际同步发生时(在想要更新您的自定义单元格之前)我假设它是通过回调完成的?如果是这样,那么执行远程 ajax 调用以更新值的回调可以更新 this.state.rows.customProp (this.state.rows.whatever.customProp) 并且一旦状态发生变化并假设您的 getRows()是从 this.state.rows 获取的,那么这一切都会自动发生。更糟糕的情况是,您可能必须在更改状态值后添加对 this.forceupdate() 的调用。这是基于我听起来相似且有效的东西...
//column data inside constructor (could be a const outside component as well)
this.columnData = [
{
key: whatever,
name: whatever,
...
formatter: (props)=>(<div className={props.dependentValues.isSynced? "green-bg" : "")} onClick={(evt)=>this.clickedToggleButton} >{props.value}</div>),
getRowMetaData: (data)=>(data),
},
...
}
]
这是我的数据网格包装器组件中的回调函数...
//when a span
clickedToggleButton(evt, props){
//do remote ajax call we have an ajax wrapper util we created so pseudo code...
MyUtil.call(url, params, callback: (response)=>{
if(this.response.success){
let rows = this.state.rows;
let isFound = false;
for(let obj of rows){
if(obj.id==props.changedId){
obj.isSynced = true;
isFound = true;
break;
}
}
//not sure if this is needed or not...
if(isFound){ this.forceUpdate(); }
}
}
}
不确定这是否有帮助,但可能会让你开始