/// <summary> /// Factory function for the notification items /// </summary> /// <param name="sId">sId The id for the item</param> /// <param name="oBindingContext">The binding context for the item</param> /// <returns>The new notification list item</returns> public sap.ui.core.Element _createNotification(string sId, sap.ui.model.Context oBindingContext) { Notification oBindingObject = oBindingContext.getObject <Notification>(); sap.m.NotificationListItem oNotificationItem = new sap.m.NotificationListItem(new sap.m.NotificationListItem.Settings() { title = oBindingObject.title, description = oBindingObject.description, priority = oBindingObject.priority, close = ([email protected] oEvent, object oData) => { var source = oEvent.getSource <sap.m.NotificationListItem>(); string sBindingPath = source.getCustomData()[0].getValue <string>(); string sIndex = sBindingPath.Split('/').Last(); List <Notification> aItems = source.getModelFor <AlertsModel>("alerts").getPropertyFor(p => p.alerts.notifications).ToList(); aItems.RemoveRange(Script.ParseInt(sIndex), 1); source.getModelFor <AlertsModel>("alerts").setPropertyFor(p => p.alerts.notifications, aItems.ToArray()); source.getModel <sap.ui.model.json.JSONModel>("alerts").updateBindings(true); sap.m.MessageToast.show("Notification has been deleted."); }, datetime = oBindingObject.date, authorPicture = oBindingObject.icon, press = ([email protected] oEvent, object oData) => { }, customData = new sap.ui.core.CustomData[] { new sap.ui.core.CustomData(new sap.ui.core.CustomData.Settings() { key = "path", value = oBindingContext.getPath() }) } }); return(oNotificationItem); }
public sap.ui.core.Element _createError(string sId, sap.ui.model.Context oBindingContext) { Error oBindingObject = oBindingContext.getObject <Error>(); sap.m.Link oLink = new sap.m.Link(new sap.m.Link.Settings() { text = "More Details", press = ([email protected] oEvent, object oData) => { sap.m.MessageToast.show("More Details was pressed"); } }); sap.m.MessagePopoverItem oMessageItem = new sap.m.MessagePopoverItem(new sap.m.MessagePopoverItem.Settings() { title = oBindingObject.title, subtitle = oBindingObject.subTitle, description = oBindingObject.description, counter = oBindingObject.counter, link = oLink }); return(oMessageItem); }