我有一个带有复选框的列表,这些复选框按顶部打勾排序,而不是在底部打勾。
我已经安排了分拣机,并且它会在勾选时刷新,但无论我选择哪个复选框,它都会保留,但标签实际上会移动。
列表会自动刷新,Front Shop项目会移动到顶部(当分拣机就位时),但是在我选中位置3的复选框的情况下,在刷新后,刻度线会保留在那里。
查看
<List id="listCategories" noDataText="{i18n>noCategories}" items="{path:'/CategorySet',parameters:{select:'CategoryDesc,CategoryId,Active'},sorter:[{path:'Active',descending:true},{path:'CategoryDesc',descending:false}]}" headerText="{i18n>active}" class="sapUiMediumMarginTop rightAlign">
<items>
<InputListItem label="{CategoryDesc}">
<!-- If there is an X in the Active field, set the state of the CheckBox to TRUE -->
<CheckBox selected="{= ${Active} ==='X' ? true : false }" select="onSwitch"/>
</InputListItem>
</items>
</List>
控制器
// Set CheckBox status, X for true, blank for false
onSwitch: function(oEvent) {
var oEntry = {};
var bindingContext = oEvent.getSource().getBindingContext();
var path = bindingContext.getPath();
var object = bindingContext.getModel().getProperty(path);
oEntry.CategoryId = object.CategoryId;
oEntry.CategoryDesc = object.CategoryDesc;
if (oEvent.getParameter("selected") === true) {
oEntry.Active = "X";
} else {
oEntry.Active = "";
}
var oModel = this.getView().getModel();
oModel.create("/CategorySet", oEntry, {
success: function() {
if (oEntry.Active === "X") {
MessageToast.show("Category set as Active", { duration: 2000 });
}
if (oEntry.Active === "") {
MessageToast.show("Category set as Inactive", { duration: 2000 });
}
},
error: function(oError) {}
});
},