I'm trying to show sap.m.Select when dialog pop up. And my dialog is opening when I press a button. So I create sap.m.Dialog dynamically when user press the button. Here how I create my dialog in controller in buttonPress function:
that = this;
var dialog = new Dialog({
id : 'reasonDialog',
title: 'Reason',
type: 'Message',
content: [
that.reasonTypeSelect,
new TextArea('id1Textarea', {
width: '100%',
maxLength: 100,
placeholder: 'Enter a reason explanation'
})
],
beginButton: new sap.m.Button({
text: 'Confirm',
press: function () {
MessageToast.show('Succesfully confirmed');
dialog.close();
}
}),
endButton: new sap.m.Button({
text: 'Cancel',
press: function () {
dialog.close();
}
}),
afterClose: function() {
dialog.destroy();
}
});
dialog.open();
and I'm creating that.reasonTypeSelect in onAfterRendering function as below :
var oItemSelectTemplate = new sap.ui.core.Item({
key : "{key}",
text : "{value}"
});
this.reasonTypeSelect= new sap.m.Select({ id: 'selectReasonTypeId',
width:'100%',
change:'handleReasonTypeSelect'
});
this.reasonTypeSelect.setModel(this.getView().getModel());
this.reasonTypeSelect.bindAggregation("items", "/ReasonTypeList", oItemSelectTemplate);
Here I can see the Select but there is no items in it.
Seems you model is not visible from the dialog component, try setting your model
oDialog.setModel(yourModel);
If it doesn't work try to do it in the "onAfterRendering" callback.
onAfterRendering: function() {
var oDialog = sap.ui.getCore().byId("reasonDialog");
oDialog.setModel(this.getView().getModel("YourModel"));
}
Related
I need to add more items to the SelectDialog control based on the Odata from the backend based on a condition. The code is,
if (!this._oDialog) {
this._oDialog = new sap.m.SelectDialog({});
this._oDialog.setModel(oParentModel);
this._oDialog.bindAggregation("items", {
path: "/et_getSidSet",
template: new sap.m.StandardListItem({
title: "{Sid}"
})
});
if (v === '1') {
var oItem1 = new sap.m.StandardListItem({
title: 'PC2',
type: 'Active'
});
this._oDialog.addItem(oItem1);
} else if (v === '2') {
var oItem1 = new sap.m.StandardListItem({
title: 'AC2',
type: 'Active'
});
this._oDialog.addItem(oItem1);
var oItem2 = new sap.m.StandardListItem({
title: 'IC2',
type: 'Active'
});
this._oDialog.addItem(oItem2);
}}
The issue is, when I click on helprequest icon, the item is not adding for the very first time. However, its added from second time onwards.
I need the item to get added for the first time.
Thanks in advance!
Using SAPUI5's JSView to create the dialog and Radial Chart, triggered by button press event, you can have a look at the full application here Plunkr Example
openDialog: function() {
if (!this.draggableDialog) {
this.draggableDialog = new Dialog({
title: "Charts",
type: "Message",
contentWidth: "900px",
contentHeight: "700px",
resizable: true,
content: [
new RadialMicroChart({
percentage: 75,
total: 100,
size: "Responsive",
valueColor: "Critical"
})
],
beginButton: new Button({
text: "Close",
press: function() {
this.draggableDialog.close();
}.bind(this)
})
});
this.getView().addDependent(this.draggableDialog);
}
this.draggableDialog.open();
}
My Goal is to launch a popup or dialog or messagebox whatever pops up and is able to contain the graph.
Dialog is working but chart data is not coming in sapui5
Using SAPUI5's JSView to create the dialog and Radial Chart, triggered by button press event, you can have a look at the full application here SAPUI5 Dialog
openDialog: function() {
if (!this.draggableDialog) {
this.draggableDialog = new Dialog({
title: "Charts",
type: "Message",
contentWidth: "900px",
contentHeight: "700px",
resizable: true,
content: [
new RadialMicroChart({
percentage: 75,
total: 100,
size: "Responsive",
valueColor: "Critical"
})
],
beginButton: new Button({
text: "Close",
press: function() {
this.draggableDialog.close();
}.bind(this)
})
});
this.getView().addDependent(this.draggableDialog);
}
this.draggableDialog.open();
}
View1.Controller.js
onClickRUSSIA: function() {
var dialog = new Dialog({
title: 'Default Message',`enter code here`
type: 'Message',
content: new Text({
text: 'Country : RUSSIA \n Contenent : ASIA \n language:RUSSIAN.'
}),
beginButton: new Button({
text: 'OK',
press: function() {
dialog.close();
}
}),
endButton: new Button({
text: 'More Info',
press: function() {
//this.getRouter().navTo("mohan");
var router = sap.ui.core.UIComponent.getRouterFor();
router.navTo("View2");
}
}),
afterClose: function() {
dialog.destroy();
}
});
dialog.open();
},
Component.js
sap.ui.define([
"sap/ui/core/UIComponent",
"sap/ui/Device",
"Test1/model/models"
], function(UIComponent, Device, models) {
"use strict";
return UIComponent.extend("Test1.Component", {
metadata: {
//rootView: "test1.webapp.view.App",
manifest: "json",
routing: {
config: {
viewType: "XML",
viewPath: "test1.webapp.view",
controlId: "rootControl",
controlAggregation: "pages",
//routerClass: "Test1.controller",
transition: "slide"
},
routes: [
{
pattern: "",
name: "default",
view: "view1"
}, {
pattern: "mohan",
name: "view2",
View: "view2"
}
]
// targets: {
// page1: {
// viewName: "View1",
// viewLevel: 0
// },
// page2: {
// viewName: "View2",
// viewLevel: 1
// }
// }
}
},
init: function() {
// call the base component's init function
UIComponent.prototype.init.apply(this, arguments);
jQuery.sap.require("sap.m.routing.RouteMatchedHandler");
jQuery.sap.require("sap.ui.core.routing.HashChanger");
sap.ui.core.UIComponent.prototype.init.apply(this, arguments);
this._router = this.getRouter();
// set the device model
this.setModel(models.createDeviceModel(), "device");
//initlialize the router
this._routeHandler = new sap.m.routing.RouteMatchedHandler(this._router);
this._router.initialize();
}
});
});
You will have to get the router for your controller/view. As this is not your controller inside endButton.press(), you have to use a helper variable that.
You have to give Router.navTo() the name of the route to navigate to. So it has to be view2 instead of View2.
var that = this;
var dialog = new Dialog({
...
endButton: new Button({
text: 'More Info',
press: function() {
var router = sap.ui.core.UIComponent.getRouterFor(that);
router.navTo("view2");
}
}),
...
this.getOwnerComponent().getTargets().display("page1");
How to pass selected Value form Popup to normal controller page in ionic framework
`$scope.showprofpopup = function()
{
$scope.data = {}
var myPopup = $ionicPopup.show
({
templateUrl: 'templates/popover.html',
title: 'Please Choose Category',
scope: $scope,
buttons: [ { text : 'Cancel' }, { text: 'Select', type: 'button-dark', onTap: function(e) { return $scope.data; } }, ]
});
myPopup.then(function(res)
{
//$scope.create(res.category);
//$state.go('app.userdetails');
//$scope.contactMessage = { text: res };
if(!res.category)
{
$ionicLoading.show({ template: '<ion-spinner icon="android"></ion-spinner>', animation: 'fade-in', showBackdrop: true, maxWidth: 100,showDelay: 50 });
$scope.showprofpopup();
$timeout(function () { $ionicLoading.hide(); }, 3000);
//$ionicPopup.alert({ title: "Please Choose Category" });
}
else
{
$scope.SelectedProfessional = { text: res.category};
//alert(res.category);
$state.go('app.userdetails');
}
});
};`
I want to send the result re.category to app.userdetails page.kindly anyone help me.
using $stateParams
$state.go('app.userdetails',{'category': res.category});
I have a form field and i want to read the text entered into it, i tried the following code:
this.searchButton = new Ext.Button({// The button press will invoke the search action
text: 'Go',
handler: this.searchButtonTap,
scope: this
});
this.topToolbar = new Ext.form.FormPanel({
items: [
{xtype: 'textfield',
name: 'search',
placeHolder: 'Search'},
this.searchButton
]
});
searchButtonTap: function () {
// console.log(this.topToolbar.items.items[1]);
var currentText = AsApp.views.AsListView.getRecord();
console.log(currentText);
},
you may try this:
this.searchField = new Ext.form.Text({
displayField: 'name',
valueField: 'name',
editable: true,
forceSelection: true,
triggerAction: 'all',
emptyText: 'Search...',
selectOnFocus: true
});
this.searchButton = new Ext.Button({// The button press will invoke the search action
text: 'Go',
handler: this.searchButtonTap,
scope: this
});
this.topToolbar = new Ext.Toolbar({
items: [
{ xtype: 'spacer' },
this.searchField,
this.searchButton,
{ xtype: 'spacer' },
]
});
searchButtonTap: function () {
var searchText = this.searchField.getValue();
console.log(searchText);
},
To get the value of a textfield, use the field's getValue() method.
For example:
var field = myTextField;
var currentText = field.getValue();
You can also use searchfield instead of textfield. It also has the getValue() method available.