merge various Cells in bootstrap Table
See original GitHub issueI’m new to bootstrap table, I’m using the method MergeCells bootstraptable, I once operated at what I did the following code to unify several rows, I wonder what I’m doing wrong.
$(function () {
var table = document.getElementById('table');
var rowLength = table.rows.length - 1;
var count = 0;
var row = table.rows[1].cells[0].innerHTML;
var saveIndex = 0;
for (var i = 0; i < rowLength; i += 1) {
if (row === table.rows[i].cells[0].innerHTML) {
count++;
} else {
row === table.rows[i].cells[0].innerHTML;
mergeRows(saveIndex, count);
saveIndex = i;
count = 0;
}
}
});
function mergeRows(index, rowspan) {
$('#table').bootstrapTable('mergeCells', {
index: index,
field: 'ciudad',
rowspan: rowspan
});
}
What I do is call bootstrap function and unify according to the types of records
Issue Analytics
- State:
- Created 8 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Creating merged table cells using Twitter Bootstrap
Break up your table headers into rows, according to their levels. So the first table row will consist of your "parent" headers, i.e....
Read more >How to combine or merge cells in an HTML table
Highlight two or more cells in your table. · Right-click the highlighted cells. · Click Modify and then select Merge Cells.
Read more >FAQ - Bootstrap Table
How to better merge cells? For merged cells, when you do refresh, next page or switch columns to show, the merge cells will...
Read more >Merge cells vertically from a table - Material Design for Bootstrap
Hi,. may you use our snippets (https://mdbootstrap.com/snippets) to show your example? Thank you. Best,. Piotr.
Read more >Tables - Bootstrap
Add .table-bordered for borders on all sides of the table and cells. #, First, Last, Handle. 1, Mark, Otto, @mdo. 2, Jacob, Thornton ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Solution: http://jsfiddle.net/dabros/sz42rymd/4/
Read the lines i changed carefully, your use of starting ints was wrong (super obvious when debugging) and placing console.log calls in merging function helped fix saveIndex issue.
Seemed to be indexing and a typo on your part (what was the second “===” doing there in an assignment???)
Still, read note in previous comment and refactor that code into a ‘OnPostBody’ or similar callback if still wanting to use it, even if you dont intent to add sorting, filters or any more functionality to the table - its still better form in case you use that code anywhere else or go back to it later to add more.
Its not thoroughly tested either, but should work on any data-set size.
For future referance, always debug first - liberal use of console.log is recommended (see my fiddle). 90% of the time it is always something simple like indexing or variable mismatch, which is why console exists : )
thanks @dabros 👍