I have a sorting issue when using rows with colspans when sorting a Footable table.
My table structure:
<table class="table footable">
<thead>
<tr>
<th>Name</th>
<th data-type="numeric">Date of Birth</th>
<th>Country</th>
</tr>
<thead>
<tbody>
<tr>
<td>Bill Smith</td>
<td data-value="315532800">1/1/1980</td>
<td>England</td>
</tr>
<tr>
<td colspan="3">Some long description of Bill<td>
</tr>
<!-- Many, many other rows -->
</tbody>
</table>
I have a checkbox to toggle the colspan rows on/off, but if they're displayed and you sort by a column, all the colspan rows are grouped together.
JSFiddle demo
Is there a way to sort that correctly places the colspan (description) row beneath the correct data row?
I've managed to solve this with Javascript (using jQuery).
Basically I'm hiding the "description" rows by default (in CSS), I have a checkbox to toggle their visibility.
My javascript hooks into Footable's sorted (after sorting) event and basically moves the description rows around so they're always below the "data" row.
$('#details').footable().bind({
'footable_sorted': function(e) {
var rows = $('#details tbody tr.data');
rows.each(function()
{
var personid = $(this).data('row-person');
var detail = $('#details tbody tr.descriptions[data-detail-person="'+ personid +'"]');
$(detail).insertAfter($(this));
});
}
});
I also had to add additional markup to my table (classes/ids) to enable this.
See my Fiddler demo for full details.
Tested with up to 370 rows and gives acceptable performance.
I'm sure my HTML/JS could be stream-lined further.
So the root of the problem is that the description row is a separate row and is not "linked" with the data row above it. The only way a user would know what data row the description row belongs to is the order of the rows. Once you sort the table, the order changes and you can no longer count on the order to link the data and description rows. (Wow that's kind of hard to read. My apologies in advance...)
So, one way to solve this is to have the data and description rows both contained in the same row.
<table>
<thead>
<tr>
<th>Name</th>
<th data-type="numeric">Date of Birth</th>
<th>Country</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<table>
<tr>
<td>Bill Smith</td>
<td data-value="315532800">1/1/1980</td>
<td>England</td>
</tr>
<tr>
<td colspan="3">Some long description of Bill</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table>
<tr>
<td>John Smith</td>
<td data-value="315532800">1/1/1980</td>
<td>France</td>
</tr>
<tr>
<td colspan="3">Some long description of John</td>
</tr>
</table>
</td>
</tr>
</tbody>
</table>
Here's a plunk that shows this in action: http://plnkr.co/edit/NvmUgzvaAix1x7WUGYSM
This is a fix for rows with colspan: $('table.footable').find('td[colspan]').siblings().remove();
Related
I am trying to use TinyMCE to allow my users to modify a handlebars report template. The template contains several elements that are not valid to TinyMCE and they are being moved around. See the {{#each data}} and {{/each}}
Here is good HTML code for my handlebars template:
<table class="table table-bordered">
<thead>
<tr>
<th><h4>Item</h4></th>
<th><h4 class="text-right">Quantity</h4></th>
<th><h4 class="text-right">Rate/Price</h4></th>
<th><h4 class="text-right">Sub Total</h4></th>
</tr>
</thead>
<tbody>
{{#each Details}}
<tr>
<td>{{Item}}<br><small>{{Description}}</small></td>
<td class="text-right">{{Quantity}}</td>
<td class="text-right">{{Rate}} {{UnitOfMeasure}}</td>
<td class="text-right">{{Amount}}</td>
</tr>
{{/each}}
</tbody>
</table>
After I past the code into TinyMCE, it results to the following:
{{#each Details}}{{/each}}
<table class="table table-bordered">
<thead>
<tr><th>
<h4>Item</h4>
</th><th>
<h4 class="text-right">Quantity</h4>
</th><th>
<h4 class="text-right">Rate/Price</h4>
</th><th>
<h4 class="text-right">Sub Total</h4>
</th></tr>
</thead>
<tbody>
<tr>
<td>{{Item}}<br /><small>{{Description}}</small></td>
<td class="text-right">{{Quantity}}</td>
<td class="text-right">{{Rate}} {{UnitOfMeasure}}</td>
<td class="text-right">{{Amount}}</td>
</tr>
</tbody>
</table>
Has anyone ran across a plugin or something else that may help me?
I just ran into this... I have an order confirmation email that I need to be configurable with a list of order items in a table; same issue.
I did just realize I probably shouldn't be using tables anyway, since they are not responsive, but I ultimately was able to solve the problem with HTML comments, like this:
<tr style="font-weight: bold;">
<td style="width: 145px;">Qty</td>
<td>Item</td>
<td>Unit Price</td>
<td>Total</td>
</tr>
<!--{{#order.line_items}} -->
<tr repeat="">
<td style="width: 145px;">{{quantity}}</td>
<td>{{product.name}}</td>
<td>{{currency unit_price}}</td>
<td>{{currency total}}</td>
</tr>
<!--{{/order.line_items}} -->
<tr>
<td style="width: 145px;"> </td>
<td> </td>
<td><strong>Subtotal:</strong></td>
<td>{{currency order.subtotal}}</td>
</tr>
I was able to use a custom attribute on my Element and use:
<tr repeat="{{#each Details}}">
</tr repeat="{{/each}}">
I have these badges in my Github repo:
How can I make them align to left (the 2 above) and to right the one under?
They are in the format ![description](url)
One way would be to use html table (since markdown table in GFM doesn't support merged cell)
this, for instance, seems to align the pictures properly within a README.md file.
<table >
<tr>
<td align="left"><img src="http://icons.iconarchive.com/icons/iconka/cat-commerce/48/add-icon.png"/></td>
<td align="right"><img src="http://icons.iconarchive.com/icons/iconka/cat-commerce/48/info-icon.png"/></td>
</tr>
<tr>
<td colspan="2"><img src="http://icons.iconarchive.com/icons/shwz/disney/512/pumbaa-icon.png"/></td>
</tr>
</table>
Result:
In your case:
<table>
<tr >
<td><img src="https://api.travis-ci.org/axemclion/grunt-saucelabs.png?branch=master"/></td>
<td align="right"><img src="https://saucelabs.com/buildstatus/grunt-sauce"/></td>
</tr>
<tr>
<td colspan="2"><img src="https://saucelabs.com/browser-matrix/grunt-sauce.svg"/></td>
</tr>
</table>
Which gives:
I got this error in inspector:
Error: [ngRepeat:dupes] http://errors.angularjs.org/1.2.9/ngRepeat/dupes?p0=subject%20in%20subjects&p1=string%3A%D0%90%D1%81%D1%82%D1%80%D0%BE%D0%BD%D0%BE%D0%BC%D0%B8%D1%8F
at Error (<anonymous>)
at http://vedomosti/js/angular.min.js:6:449
at http://vedomosti/js/angular.min.js:184:445
at Object.fn (http://vedomosti/js/angular.min.js:99:371)
at h.$digest (http://vedomosti/js/angular.min.js:100:299)
at h.$apply (http://vedomosti/js/angular.min.js:103:100)
at f (http://vedomosti/js/angular.min.js:67:98)
at E (http://vedomosti/js/angular.min.js:71:85)
at XMLHttpRequest.v.onreadystatechange (http://vedomosti/js/angular.min.js:72:133) angular.min.js:84
But I don't understand where my mistake...
I'm writing an application for school. I have table school in MySQL.
With fields:
id, name, 1,2,3,4,5,6,7,8,9,10,11
1,2,3,4... it's classes and they are have information about subjects. Each class have their subjects. Now I'm writing part, in which user can set subjects into classes. 1 to 10 classes all works good. But when I click "load subjects from 11 class", I get this error.
This table with subjects:
div class="large-6 column">
<label>Предметы {{class}} класса</label>
<table>
<thead>
<tr>
<th style="width: 200px;">Предмет</th>
<th style="width: 200px;">Изменить</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="subject in subjects">
<td>{{subject}}</td>
<td><a>изменить</a></td>
</tr>
</tbody>
</table>
</div>
And button for load information other classes:
<button class="button success tiny" ng-click="getSCLASS()">получить</button>
And function for this button:
$scope.getSCLASS = function(){
$http.post("/index.php/panel/getSCLASS", {class:$scope.class}).success(function(data){
$scope.subjects = data;
$scope.s_subjects = true;
});
}
From 1 to 10 classes - all works good. But with 11 class it's not work. I don't understand where my mistake.
Sorry for my English :|
See this and try this:
<div class="large-6 column">
<label>Предметы {{class}} класса</label>
<table>
<thead>
<tr>
<th style="width: 200px;">Предмет</th>
<th style="width: 200px;">Изменить</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="subject in subjects track by $index">
<td>{{subject}}</td>
<td><a>изменить</a></td>
</tr>
</tbody>
</table>
</div>
I have table with id parentTable. Also there is child table in the third column of every row. When i count the length of rows of parent table it gives me sum of rows of parent and child table. Also this happens with the tds. How do i achieve this for getting/iterating rows of parent table only and interating tds of parent rows only. I tried $('parentTable >tbody>tr') but not worked for me. Please assist. Below is the sample.
<table id="parentTable"><tr>
<td></td>
<td></td>
<td>
<table>
<tr>
<td></td><td></td>
</tr>
<tr>
<td></td><td></td>
</tr>
</table>
</td>
</tr>
<td></td>
<td></td>
<td>
<table>
<tr>
<td></td><td></td>
</tr>
<tr>
<td></td><td></td>
</tr>
</table>
</td>
</tr>
</table>
You can assign different classes to the rows (tr s) of the parent table, and the child table. And use those classes for selecting them. You can do the same for the cells (tds) too.
For example, you if your table looks like -
<table class="parentTable">
<tr class="parentRow">
<td class="parentCell">Cell 1</td>
<td class="parentCell">Cell 2</td>
<td class="parentCell">
<table class="childTable">
<tr class="childRow">
<td class="childCell">Cell 31</td>
<td class="childCell">Cell 32</td>
<td class="childCell">Cell 33</td>
</tr>
</table>
</td>
</tr>
</table>
In your jquery, to get just the parent rows and their cells you can use
$.each($(".parentRow"), function() {
$.each($(this).find(".parentCell"), function() {
//Do Something
});
});
I have my template set up to repeat a block of html between the |RSSITEMS:| tag, but my question is how to limit the number of times that block gets repeated.
Thank you in advance.
The best solution that I've found is to use MailChimps |FEEDITEMS| merge tag as it offers more granular control than the |RSSITEMS| tag. Here's a snippet for creating a repeatable block that only pulls the 5 most recent items in an automated-RSS campaign (notice the "$count=" declaration):
*|FEEDBLOCK:http://website.com/feed/|*
<table width="600" align="center" cellpadding="0" cellspacing="0">
*|FEEDITEMS:[$count=5]|*
<tr>
<td valign="middle" align="center">*|FEEDITEM:TITLE|*</td>
</tr>
<tr>
<td valign="middle" align="center">*|FEEDITEM:DATE|*</td>
</tr>
<tr>
<td valign="middle" align="center">*|FEEDITEM:CONTENT_FULL|*</td>
</tr>
*|END:FEEDITEMS|*
</table>
*|END:FEEDBLOCK|*