我正在使用 w2ui v1.5 并具有以下“设计”
html:
<body>
<div id="myGrid" style="width:100%; height: 100vh"></div>
</body>
脚本:
w2ui.myGrid.on('change',(event)=>{
if(event.value_new !== event.value_previous) {
const previousNote = event.value_previous;
const updatedNote = event.value_new;
const customId = event.recid;
$.ajax({
url:`/stuff/${customId}`,
type:'PUT',
contentType:'application/json',
data:JSON.stringify({
previousNote,
updatedNote,
})
}).done((data, textStatus, xhr) => {
console.log('DONE--->',data,'status',textStatus,'xhr',xhr); //NOOP
}).fail((xhr, textStatus, errorThrown)=>{
conflictPopup(customId, xhr.responseJSON);
});
}
});
在弹出窗口中,我尝试在显示详细信息后恢复为旧值:
const conflictPopup = (customId, data) => {
w2ui.myGrid.set(customId,{userNotes:data.previousNote}); //DOESN'T WORK
w2popup.open({
title: 'CONFLICT - STALE DATA',
body: 'oops!',
actions: {
Ok(event) {
//even this doesn't work
w2popup.close();
w2ui['myGrid'].set(customId,{userNotes: data.currentValue});
w2ui['myGrid'].refresh();//(customId,'userNotes');
}
}
});
}
网格继续显示陈旧的数据。我什至尝试打电话w2ui.myGrid.refresh()但无济于事。我什至尝试使用w2ui.myGrid.refreshCell(customId,data.previousNote),即使那样也行不通。
调用refresh或手动触发事件的组合不会强制 UI 更新。如果我w2ui.myGrid.records在控制台上执行此操作,我会看到具有正确值的数据结构,userNotes但即使在控制台上调用该方法后网格似乎也没有刷新。我错过了什么?