How can you push a screen on top of a TabbedPane?
I know this is possible with a NavigationPane like below :
NavigationPane {
id: navigationPane
Page {
Container {
Label {
text: "First page"
}
}
actions: [
ActionItem {
title: "Next page"
onTriggered: {
var page = pageDefinition.createObject();
navigationPane.push(page);
attachedObjects: ComponentDefinition {
id: pageDefinition;
source: "secondpage.qml"
}
}
]
}
...
But I try the same on a TabbedPane and it fails because there is no push method for TabbedPanes.
The scenario is to push an about screen using Application menus.
Help..?
There is no metaphor for pushing a Tab onto a TabbedPane. If the Tab already exists as a child of the TabbedPane you can make it the active Tab by calling setActiveTab()
If the Tab is not already a child of the TabbedPane you will have to add() it first.
But it sounds like what you really want is a Sheet
Page {
attachedObjects: [
Sheet {
id: mySheet
content: Page {
Button {
text: "Close Sheet"
onClicked: mySheet.close()
}
}
}
]
actions: [
ActionItem {
title: "Show Sheet"
ActionBar.placement: ActionBarPlacement.OnBar
onTriggered: {
mySheet.open();
}
}
]
}
Related
I am trying to get two confirmations from user one after another. If the first one is cancelled, there is no need to get the second one. But if the first one is agreed on, then the second one should be shown and processed. I am using a piece of code like this
showConfirmation1() {
let confirm = this.alertCtrl.create({
title: 'C1',
message: "M1",
buttons: [
{
text: 'No',
},
{
text: 'Yes',
handler: data => {
this.showConfirmation2();
}
}
]
});
showConfirmation2() {
let confirm = this.alertCtrl.create({
title: 'C2',
message: "M2",
buttons: [
{
text: 'No',
},
{
text: 'Yes',
handler: data => {
this.doYourJob();
}
}
]
});
If user cancels the first one, everything works fine. If user accepts the first one, the second one is shown properly. However, the second one kinda freezes. Neither its No button nor its Yes button work. It does not even vanishes when you click on other areas of the page.
UPDATE:
Found a cleaner solution that requires less code and is easier to understand.
By returning false in the button handler you prevent the alert from closing. And the dismiss-function returns a Promise that gets resolved when the transition is complete. So thats where we will call the function to open the second alert.
showConfirmation1() {
let confirm = this.alertCtrl.create({
title: 'C1',
message: "M1",
buttons: [
{
text: 'No',
},
{
text: 'Yes',
handler: data => {
confirm.dismiss()
.then(() => {
this.showConfirmation2();
});
return false;
}
}
]
});
confirm.present();
}
ORIGINAL:
Make use of the dismiss(data:any) function on your first alert. And pass a value that indicates that it was not cancelled. In the onDidDismiss-function check for this value. If its there present the second alert.
showConfirmation1() {
let confirm = this.alertCtrl.create({
title: 'C1',
message: "M1",
buttons: [
{
text: 'No',
},
{
text: 'Yes',
handler: data => {
confirm.dismiss({ showSecond: true });
return false;
}
}
]
});
confirm.onDidDismiss(data => {
if(data && data.showSecond){
this.showConfirmation2();
}
}
confirm.present();
}
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 datagrid that has additional information I'd like to show in a pop up.
I display an icon to alert the user this information exists. The icon has a click action that performs a callback to the server to get this information. When I click this, I have all my data ready to view, but am not sure of the MVVM logistics of this.
Here is a mockup of what I'm trying to do. The alert function displays a modal popup. The click handler works, and the callback works fine.
I'm wondering, where do I create the new grid model, should it be a part of the current grid model, where do I apply bindings?
var initialData = [
{ name: "ABC", number: 1, icon: true},
{ name: "DEF", number: 2, icon: false },
];
var GridModel = function(items) {
this.items = ko.observableArray(items);
this.gridViewModel = new ko.simpleGrid.viewModel({
data: this.items,
columns: [
{ headerText: "Name", rowText: "name" },
{ headerText: "Number", rowText: "number" },
{ headerText: "Addl Info",
rowText: function (item)
{
return item.icon ? "<i class=\"icon\"></i>" : "";
},
clickHandler: function (item)
{
function callback(data) {
// data is now an array of objects I want a data grid for that displays in the pop up.
alert("Additional Information", <HTML GOES HERE>);
}
$$.getJSON("url", [], callback);
}
],
});
};
ko.applyBindings(new GridModel(initialData));
In jstree , I can right click on a node and select an item from the context menu.
In the code below, I am trying to use the obj object to get the tree item. I can get that using $(obj) however this is just a HTML list item. How do I get metadata (foo) associated with that ?
$(element).jstree(
"data" : { "data" : {"title" : "An item"}, "metadata":{"foo" :"bar"}},
"plugins" : ["themes", "ui", "contextmenu"],
"contextmenu" : {
"items" : function($node) {
return {
"Menu1" : function(obj){
//my menu action
}
};
};
}
);
Here is how the metadata can be accessed.
obj.data().foo
I had the same issue, when trying to fetch the ID of a selected jsTree node.
It can be done, you just need to create your own function to populate the contextmenu, to fetch the relevant values from your JSON data:
jsTree Context Menu selected item?
In arguments of function contextmenu.items you have access of current item data. This dynamically invocable function, fired every time on new right click event on node, See example:
$('#post-tree').jstree({
core: {
data: treeData
},
plugins: ['contextmenu'],
contextmenu: {
items: function (item) {
return {
addPost: {
label: 'Add new Post',
action: function () {
console.log(item.original); // metadata object
}
},
addSubcategory: {
label: 'Add subcategory',
action: function () {
console.log('addSubcategory');
}
},
editCategory: {
label: 'Properties',
action: function () {
console.log('editCategory')
}
},
delete: {
label: 'Delete',
action: function () {
console.log('delete Category');
}
}
};
}
}
});
i have tried a onClick function in BB-10 ,while Clicking i can't able to push another qml file the on click function
Button {
text: "LOG IN"
onClicked: {
var test = screen.createObject();
navigationPane.push(test);
}
attachedObjects: ComponentDefinition {
id: screen
source: "y.qml"
}
}
The code y.qml as follows
TabbedPane {
showTabsOnActionBar: true
Tab {
title: "Home"
Page {
id: page1
actions: [
ActionItem {
title: "New"
},
ActionItem {
title: "Delete"
}
]
}
}
Tab {
title: "Options"
Page {
id: page2
actions: [
ActionItem {
title: "Edit"
},
ActionItem {
title: "Save"
}
]
}
}
I can't able to view the "y.qml" while Clicking(text: "LOG IN") button, can anyone send some solutions,to solve this problem ?
you can't push tabbed pane from navigationPage, you can only push a Page; but within TabbedPane you can have navigationpane.
you can't able to push navigation Pane to tabbed pane, you can add navigationpane inside a tab as like
Tab {
id: loginregisterTab
NavigationPane {
peekEnabled: false
id: test
y{//here u can go to y.qml
}
}
}
in y.qml u have incliude the id like
NavigationPane{
id: navigationPane
Page {
Container {
id: test
}
}
}