Ionic 2 - Tables - ionic-framework

I'd like to build tables using ionic just like in Bootstrap.
I'd like my tables to look like THIS LINK'S examples.
So, the feature that I couldn't find in Ionic's Docs was "table headers". All the examples I'm finding do not consider table headers.
Also, is there a native way in Ionic to make table rows colored like Bootstrap's "Contextual Table Layout" and responsive, like "
Responsive Table Layout" examples in this link?

You can make your ionGrid look like the ones in that link with just a few style rules. Just like you say, docs don't say anything about headers, but you can use the <strong></strong> html element there:
<!-- Header -->
<ion-row>
<ion-col>
<strong>Product</strong>
</ion-col>
<ion-col>
<strong>Payment Date</strong>
</ion-col>
<ion-col>
<strong>Status</strong>
</ion-col>
</ion-row>
And I think there's not a native way to make table rows colored like Bootstrap's "Contextual Table Layout" but you can achieve that with just a few style rules:
ion-row.active {
background-color: #f5f5f5;
}
ion-row.success {
background-color: #dff0d8;
}
ion-row.warning {
background-color: #fcf8e3;
}
ion-row.error {
background-color: #f2dede;
}
And about the Responsive Table Layout, even though we could achieve that by playing with the overflow CSS property, I don't think that's a good idea because it may affect other things like the sliding effect to open the side menu, or things like that. If the width of the table is too big to fit the screen, instead of making it scrollable a better solution would be just to show a column or two with the most important data, and include a button that takes you to a details page where you can see the rest of that information.
UPDATE
As of Ionic 3.0.0, the Grid component has been updated, and a lot of new features were included. You can take a look at this working plunker to see some of the new features of the new grid component.

Related

Making the whole ion-item in an ItemReorder draggable

In my application I've got an ItemReorder as described in the docs:
<ion-list reorder="true">
<ion-item *ngFor="let item of items">{{ item }}</ion-item>
</ion-list>
It works as intended, I can drag the ion-items by pointing at the reoder icon (see freehand circle):
Testing with potential users on a tablet I found out, many users don't see the icon at first and/or try to drag the ion-item without pointing at the icon. They expect the whole ion-item to be draggable:
How can I implement this? Any insight is appreciated!
I've already checked the docs twice, googled and found this unanswered question on the ionic forum and this plugin for Ionic v1. I also scanned the code on Github without success.
The ideea of this css solution is to have the reorder icon invisible above the zone which you want to reorder. I have changed the icons to be on the right side <ion-list side="start" and I have changed the css like this
Now for me it's working.
ion-reorder{
position: absolute;
width: 22%;
max-width: 100%;
opacity: 0;
}
The cons is that there is no more visible reorder icons.

Polymer 1.0 paper-dialog shows extremely compressed

I can't seem to get the paper-dialog to show up correctly all of the time. It will show correctly once then it will show up compressed the next time when I click on it to the point that it looks like a line. Unfortunately, I am unable to add a picture of it since this is my first question.
I have removed my styling sheets from this element but could the other styling sheets of my other element be causing this problem? Any direction of what I should look at would be really helpful.
I setup this paper dialog with the following:
<paper-dialog id='addressDialog'
opened="{{addressDialogOpened}}"
no-cancel-on-outside-click
no-cancel-on-esc-key
entry-animation="slide-from-right-animation"
exit-animation="scale-down-animation">
<div>
<template is="dom-if" if="{{newAddressDialog}}">
<h2>Add an Address</h2>
</template>
<template is="dom-if" if="{{editAddressDialog}}">
<h2>Edit Address Information</h2>
</template>
<hr>
</div>
It has a series of template repeats in it as well. I was reading about the paper dialog and it says that it has space for a header, content area, and buttons. Do I always have to set it up this way in order for it to work?
Additional solution is to add position: fixed; into your paper-dialog style like:
:host paper-dialog { position: fixed; }
So the only way that I saw to fix this terrible problem was to use a style of "min-height" and some percentage of the page. After I included this in my paper-dialog elements the popups were showing perfectly.

Ionic Framework list scrolling

I have my simple application using Ionic Framework.
It looks like :
Here the list code :
<ion-list show-Reorder="data.showReorder">
<ion-item class="item-avatar item-icon-right" ng-repeat="band in bands" type="item-text-wrap" href="#/bands/{{auth.profile.name}}/{{band.id}}">
My problem is, when I try to scroll the list up and down, it always shows blur on the selected list, and it makes the view when doing scrolls is not smooth enough.
I can solve that blur problem, but I lose the list ng-click and href capabilities, like
<ion-list show-Reorder="data.showReorder">
<ion-item class="item-avatar item-icon-right" ng-repeat="band in bands" type="item-text-wrap">
How to resolve that blur problem without losing ng-click and href capabilities, in order to make scrolls are smoother?
Try using ui-sref instead of href. If this doesn't work create an anchor link inside your ion-item and redirect through it. Hopefully this will solve your problem.

Making <table class="table"> with long horizontal rows more mobile friendly

I am using Bootstrap (2.3) on a responsive web site.
We have a lot of data tables which simply do not fit on the mobile screen horizontally, even after removing all unnecessary columns. If nothing is done, these <table>s cannot shrink enough, break mobile layout on iOS by expanding outside the page horizontal pages and triggering the page zoom (though no other elements on the page scale).
For now, the solution is to wrap <table> to overflow <div>
<div style="overflow: auto">
<table class="table>
</table>
</div>
This makes the table scrollable horizontally. Applying overflow: auto on <table> itself does not seem to do anything, so the table must be wrapped. Questions
Are there any other methods making horizontal <table>s mobile friendly? Some special CSS rules that could help here?
Could overflow: auto applied on the <table> itself through CSS pseudo selectors, so that it would overflow properly?
I've heard Foo Tables are pretty good at displaying tabular information in low resolutions/responsive environments.

Facebook like button disable the count

I added face book like button on my site is there any way to disabled the count which is display next to the button.
http://www.knowledgenotebook.com/FB/notShow.png
You can but not directly.
You have to set data-layout="box_count", wrap button code with extra element, set overflow and move button up. It will be something like that:
<style>
.fb-wrap {height:20px; overflow:hidden;}
.fb-wrap div {position:relative; top:-41px;}
</style>
<div class="fb-wrap"><div class="fb-like" data-href="http://mysite.com/" data-send="false" data-layout="box_count" data-show-faces="false"></div></div>
This will work more bulletproof than crop by width because of internationalization
Yeah, honestly I'm very disappointed that Facebook still didn't do anything to make the button configuration easier (show/hide count, change size, etc.). All the other mayor social buttons - Twitter, G+, LinkedIn, Pinterest have this option available, and there's no need to make CSS workarounds which not always work (mentioned above case of different languages).
For simple sites, just add a fixed width to the iframe ( width:47px !important; )
For the multilingual sites where you have to display the Like/Recommend text in more than one language (EN: Recommend, DE: Empfehlen) the text length is different and you can't set a fixed width, but you can use layout=box_count and set a fixed height:
height: 70px; margin-top:-41px;
You can't.
http://developers.facebook.com/docs/reference/plugins/like
The count is not a configurable attribute
You can. All you need to do is set the width to 47 in facebook's iframe code.
There are a few answers for the different cases where you can hide the count in the answers here:
Facebook Like-Button - hide count?
The side effect is that you have to hide the comment flyout as well.
The default attributes you have available are here:
http://developers.facebook.com/docs/reference/plugins/like/
The code loads an iFrame on your site and you maybe able to adjust the size of the iFrame to hide certain components based on the design "Layout Style" you choose.
You can hide it using css styles, adjusting the width and hiding overflow, but be aware it's forbidden.
Facebook Policy
IV. Application Integration Points
4 d. You must not obscure or cover elements of our social plugins, such as the Like button or Like box plugin
If you want to include a share and like button (and don't need internationalization) this works:
<style>
.fb-wrap {height:20px; overflow:hidden;}
.fb-wrap div {position:relative; left: 27px; margin-left: -27px;}
</style>
<div class="fb-wrap">
<div class="fb-like"
data-width="160"
data-layout="button_count"
data-show-faces="false"
data-send="true">
</div>
</div>
All I had to do was change data-layout attribute from "box-count" to "button". Worked fine.
<div class="fb-share-button" data-href=#longURL data-layout="button">