I know this has been addressed a few times, but I am trying to figure out the right way to architect this solution:
I have 5 tabs, where all 5 tabs, where in these tabs, I need to use the same view and the same URL for multiple tabs. For example:
feedTab (/feed, tab is tab-feed) -> checkinDetail (checkin/:checkinId) -> ItemDetail (item/:itemId)
profileTab (/profile, tab is tab-profile) -> checkinDetail (checkin/:checkinId) -> ItemDetail (item/:itemId)
Is this possible? If not - what is the best way to do this in ionic using Tabs?
I have done this, you just need to define a state for each of the possible detail views. For example:
In my application I have a detail view that can be accessed from more than one tab.
templates/ride-detail.html
I have two tabs that can access the above detail view:
tab.profile
tab.rides
and they have states defined as below:
.state('tab.profile', {
url: '/profile',
views: {
'tab-profile': {
templateUrl: 'templates/tab-profile.html',
controller: 'ProfileCtrl'
}
}
})
.state('tab.rides', {
url: '/rides',
params: {
issearch: null,
radius: null
},
views: {
'tab-rides': {
templateUrl: 'templates/tab-rides.html',
controller: 'RidesCtrl'
}
}
})
To enable the ride detail view to be accessed from the two above tabs I defined two states for this as below:
.state('tab.ride-detail', {
url: '/rides/:rideId',
views: {
'tab-rides': {
templateUrl: 'templates/ride-detail.html',
controller: 'RideDetailCtrl'
}
}
})
.state('tab.profile-detail', {
url: '/profile/:rideId',
views: {
'tab-profile': {
templateUrl: 'templates/ride-detail.html',
controller: 'RideDetailCtrl'
}
}
})
Then from the rides tab I call code below to get to detail view:
$state.go('tab.ride-detail', {
rideId: rideid
});
and from profile tab call:
$state.go('tab.profile-detail', {
rideId: rideid
});
Then in your view you can have ng-click="godetail(checkinId)"
and then change state call depending on the controller that the godetail function calls into, so in my case when godetail is called from profile tab:
$scope.godetail = function (rideid) {
$state.go('tab.profile-detail', {
rideId: rideid
});
};
and when called from rides tab:
$scope.godetail = function (rideid) {
$state.go('tab.ride-detail', {
rideId: rideid
});
};
Hope this helps.
Related
ANSWER GetItemURL is only used for keyboard interactions. It is not used for the mouse handling. Mouse handling is done by the rendered HTML (from the template). The simplest approach is to use a a HREF In your template, or an OnClick handler that takes you to another page!
—————————-
I've copied the default autocomplete code for static sources, the completion and filters work, and getItemURL is called correctly, however on click the URL does not change.
I've created a sandbox you can see ithere.
Default code:
const { autocomplete } = window["#algolia/autocomplete-js"];
const autocomplete_id = "#autocomplete-search-box";
function CreateAutoComplete(appid, search_api_key, index_name) {
console.log("CreateAutoComplete Called");
autocomplete({
container: autocomplete_id,
placeholder: "Type T to get completions",
getSources() {
return [
{
sourceId: "links",
getItems({ query }) {
const items = [
{ label: "Twitter", url: "https://twitter.com" },
{ label: "GitHub", url: "https://github.com" }
];
return items.filter(({ label }) =>
label.toLowerCase().includes(query.toLowerCase())
);
},
getItemUrl({ item }) {
console.log("GetItemURL", item);
console.log("returning", item.url);
return item.url;
},
templates: {
item({ item }) {
return item.label;
}
}
}
];
}
});
}
Remember that getItemUrl() is expecting a keyboard interaction (navigate via arrows and click enter) to navigate over to the result URL, not a click.
This is working in your codesandbox, although the redirect is being blocked by Twitter/Github.
After a lot of searches in SO without any particular solution, I am compelled to ask this question.
What I want is to hide a row group icon on a single group row. Like in the below picture I have a group row that has only one record, which is already shown in the top row. I want to hide that collapse icon on that single record. Only collapse/expand icon shown when group rows are more than one.
For reference see AG-Grid Master-Detail Section, here they specify which rows to expand. Same functionality I needed here.
I'm using the below versions of AG-Grid Angular (v9)
"#ag-grid-community/core": "^25.3.0",
"#ag-grid-enterprise/row-grouping": "^26.0.0",
"#ag-grid-enterprise/server-side-row-model": "^25.3.0",
"ag-grid-angular": "^25.3.0",
"ag-grid-community": "^25.3.0",
Here is my code:
this.rowModelType = 'serverSide';
this.serverSideStoreType = 'partial';
this.cacheBlockSize = 20;
this.gridOptions = {
rowData: this.loanlist,
columnDefs: this.generateColumns(),
getNodeChildDetails: function(rowItem) {
if (rowItem.orderCount > 1) {
return {
expanded: true
}
} else {
return null;
}
}
}
The issue is the getNodeChildDetails is not accessible. Browser console showing me the below warning and my above code is not working.
This is simple to achieve using a cellRendererSelector on the autoGroupColumnDef. You can specify whether to show the default agGroupCellRenderer or simply return another renderer (or, just return null):
this.autoGroupColumnDef = {
cellRendererSelector: (params) => {
if (params.value == 'United States') {
return null;
} else {
return {
component: 'agGroupCellRenderer',
};
}
},
};
In the example below, we are disabling the row group expand functionality on the United States row.
See this implemented in the following plunkr.
The solution isn't that hard - but could be tough, agreed (one day faced with the same case)
So - the answer is custom cell renderer.
It would look a little bit different (separate column for collapse\expande action) - but you would get all control of it.
Custom rendeder component for this action would look like :
template: `
<em
[ngClass]="{'icon-arrow-down':params.node.expanded, 'icon-arrow-right': !params.node.expanded}"
*ngIf="yourFunctionHere()"
(click)="toggleClick()">
</em>`,
export class MasterDetailActionComponent implements ICellRendererAngularComp {
private params: any;
agInit(params: any): void {
this.params = params;
}
public toggleClick(): void {
this.params.node.setExpanded(!this.params.node.expanded);
}
public yourFunctionHere(): boolean {
// so here you are able to access grid api via params.api
// but anyway params.node - would give you everything related to row also
}
refresh(): boolean {
return false;
}
}
in [ngClass] - you are able to handle the visual part (icons) - modify\customize
and don't forget to add this component in the gridOptions:
frameworkComponents: {
'masterDetailActionCellRenderer': MasterDetailActionComponent,
}
and include this column in your columnDef:
columnDefs: [
headerName: "",
width: 75,
field: "expand",
cellRenderer: "masterDetailActionCellRenderer",
filter: false,
resizable: true,
suppressMenu: true,
sortable: false,
suppressMovable: false,
lockVisible: true,
getQuickFilterText: (params) => { return '' }
]
I've a custom control which have multiple properties inserted in Detail View page. I've binded data with these properties. Scenario is I've two pages one is list view and then detail view. I've to navBack from detail page and select diff product from main page.Detail view page show diff products detail according to selected product. everything works fine. but problem is that my custom control doesn't update values and other page have updated values.
<custom:product topic="" subTopic="{product>name}" id="productDetial"></custom:product>
I've used one methond this.getView().byId("productDetail").rerender(); but it doesn't update my Inner HTML of control.
the control code. might be some typos error.as I've changed some variables name and remove unwanted code. the purpose is to show the methods which I've used and how I did
sap.ui.define([
"sap/m/Label",
"sap/m/Button",
"sap/m/CustomTile"
], function(Label, Button, CustomTile) {
"use strict";
jQuery.sap.declare("testProduct.control.product");
return CustomTile.extend("testProduct.control.product", {
metadata: { // the Control API
properties: {
name: {
type: "string",
defaultValue: "--"
},
subTopic: {
type: "string",
defaultValue: "--"
}
}
},
init: function() {
},
rerender: function(oRM, oControl) {
},
renderer: function(oRM, oControl) {
oRM.write('<div class=" sapMTile customTileCourseDetail">');
oRM.write('<div class="leftTileYourScore">');
if (oControl.getSubTopic() !== "" && oControl.getSubTopic() !== undefined) {
oRM.writeEscaped(oControl.getSubTopic());
} else {
oRM.write(" ");
}
oRM.write('</div>');
oRM.write('</div>
}
});
});
Yo just need to add a setter function in you control. When the binding is refreshed/changes, UI5 will trigger a setter method specific to the property. So in you case for the property subTopic it expects a method setSubTopic. This method should define you own logic to update said property in the UI layer according to your needs.
Here is part of the code you need to add, you will also have to tweak the initial rendering logic a bit.
renderer: function (oRM, oControl) {
//oRM.write('<div class=" sapMTile customTileCourseDetail">');
oRM.write("<div")
oRM.writeControlData(oControl);
oRM.addClass("sapMTile customTileCourseDetail");
oRM.writeClasses();
oRM.write(">");
oRM.write('<div class="leftTileYourScore">');
if (oControl.getSubTopic() !== "" && oControl.getSubTopic() !== undefined) {
oRM.writeEscaped(oControl.getSubTopic());
} else {
oRM.write(" ");
}
oRM.write('</div>');
oRM.write('</div>');
},
setSubTopic: function(sText){
this.setProperty("subTopic", sText, true);
$("#"+this.sId+" .leftTileYourScore").html(sText);
}
I'm trying to create a very simple lookbook application. Yet I can't seem to get the routes to work. I tried the answer to this question to debug the routes. Nothing appeared in the console.
I'm trying to create an application where the user sees several looks on a page and can then navigate to the respective details page. It would be nice if Ionic also recognizes that the details page is a child page of the lookbook page. Thus showing the back button in the menu bar.
The app.config route setup code:
$stateProvider
//Lookbook view
.state('lookbook', {
url: '/lookbook',
views: {
'main': {
templateUrl: 'templates/lookbook.html',
controller: function () {
console.log('Lookbook controller loaded!');
}
}
}
})
// Details view
.state('lookbook.brand-shirt', {
url: '/lookbook/brand-shirt',
views: {
'main': {
templateUrl: 'templates/brand/shirt.html',
controller: function () {
console.log('Details controller loaded!');
}
}
}
});
$urlRouterProvider.otherwise('/lookbook');
The index.html <body> contents:
<ion-nav-bar class="bar-stable">
<ion-nav-back-button>
</ion-nav-back-button>
<ion-nav-title>
<img class="logo" alt="Lookbook Logo" ng-src="assets/images/icons/logo.svg">
</ion-nav-title>
</ion-nav-bar>
<ion-nav-view name="main">
</ion-nav-view>
The lookbook page shows up. But when I navigate to /lookbook/brand-shirt it reverts back to /lookbook.
What is it that I'm missing?
In that routing, the brand-shirt state is a child of the lookbook state (lookbook.brand-shirt), as you don`t want to load the detail INSIDE the lookbook view, you don't need to make it like that.
$stateProvider
//Lookbook view
.state('lookbook', {
url: '/lookbook',
views: {
'main': {
templateUrl: 'templates/lookbook.html',
controller: function() {
console.log('Lookbook controller loaded!');
}
}
}
})
// Details view
.state('brand-shirt', {
url: '/lookbook/brand-shirt',
views: {
'main': {
templateUrl: 'templates/brand/shirt.html',
controller: function() {
console.log('Details controller loaded!');
}
}
}
});
$urlRouterProvider.otherwise('/lookbook');
Do it like that. And the history will work the same because you are pushing views in your 'main' ion-nav-view. So at the start of your app /lookbook is loaded in main, when you go to brand-shirt, that new view goes above in the main views stack. If you go back, you will be removing the details view and going back to the lookbook.
CodePen
My project has a navigation view with tabs at the bottom I want when a specific tab is clicked an action sheet pops up. I tried launching a function when the controller is instantiated but that only launches the action sheet once obviously
I did a few things to make this work - not sure it is the best. First, I removed the href from a tab and the inner nav child:
I also added a ng-click action. My showActionSheet needs to defined in rootScope, not a controller, since it needs to be available no matter what controller is active. So in app.js, I added the sample code for it.
.run(function($ionicPlatform,$rootScope,$ionicActionSheet) {
$rootScope.showActionSheet = function() {
console.log("showAS");
var hideSheet = $ionicActionSheet.show({
buttons: [
{ text: '<b>Share</b> This' },
{ text: 'Move' }
],
destructiveText: 'Delete',
titleText: 'Modify your album',
cancelText: 'Cancel',
cancel: function() {
// add cancel code..
},
buttonClicked: function(index) {
return true;
}
});
};