我通过控制器使用工厂函数向SAPUI5表列项添加控件,以便我可以应用跨字段验证以及标准控件验证 . 现在验证工作正常,它显示带有红色边框的错误消息,但是当我移动到下一个控件时,控制的验证状态消失 . 我注意到它是由于SAPUI5的一些内部功能而发生的,它在HTML dom explorer中重新呈现表的表体元素,这也消除了应用于控制的错误类 . 它是第一次出现,但是当我尝试使用无效数据再次更改同一控制器的值时,它会显示错误并使用红色边框保持值状态 .

我的表XML视图

<Table id="todosTable" growing="true"  items="{
                            path: 'TripService>/todos', factory: '.populateItems'
                        }">
                        <columns>
                            <Column id="id">
                                <Text text="Id"/>
                            </Column>
                            <Column id="title">
                                <Text text="Title"/>
                            </Column>
                            <Column id="url">
                                <Text text="Url"/>
                            </Column>
                            <Column id="thumbnailUrl">
                                <Text text="Thumbnail Url"/>
                            </Column>
                        </columns>
                    </Table>

我的Controller代码用于应用列项

function populateItems(sId: any, oContext: any) {
                const idInput = new Input({
                    value: "{TripService>id}",
                    id: `id_${sId}`,
                    liveChange: onIdChange.bind(this)
                });
                const titleInput = new Input({
                    value: "{TripService>title}",
                    id: `title_${sId}`,
                    liveChange: onTitleChange.bind(this)
                });
                const urlInput = new Input({
                    value: "{TripService>url}"
                });
                const tumbnailInput = new Input({
                    value: "{TripService>thumbnailUrl}"
                });

                var row = new ColumnListItem(sId, {
                    cells: [idInput, titleInput, urlInput, tumbnailInput]
                });
                return row;
            }

function onIdChange(oEvent: any) {
   oEvent.oSource.setValueState(sap.ui.core.ValueState.Error);
}
function onTitleChange(oEvent: any) {
   oEvent.oSource.setValueState(sap.ui.core.ValueState.Error);

}

一些图像具有有效的错误状态,然后与错误的错误状态

enter image description here

enter image description here

正如你在上面两张图片中看到的那样,错误在第二张图片中消失了,虽然我希望它在那里 .