简体   繁体   English

带有Twitter Bootstrap手风琴的浓缩表

[英]Condensed table with twitter bootstrap accordion

I have this table, structured in this way: 我有此表,以这种方式构造:

Html part: HTML部分:

<table id="table_div" class="table table-striped table-condensed"><tbody></tbody></table>

JS part: JS部分:

var data = json_response['data'];

$("#table_div").html('<thead><tr><td>TIMESTAMP</td><td>VALUE</td></tr></thead>');

$.each(data, function(index, value) {
$('#table_div > tbody:last').append('<tr><td>' + value + '<td></tr>'); 
});   

This code generates me a table in the style of twitter bootstrap. 这段代码为我生成了一个Twitter引导风格的表格。 Now I would like that the table slide up and down or is formed from more and more pages. 现在,我希望表格上下滑动或由越来越多的页面组成。

I don't know if I can use and in that way the accordion tool of twitter bootstrap. 我不知道我是否可以使用Twitter Bootstrap的手风琴工具。 Or any other script. 或任何其他脚本。 Can you help me? 你能帮助我吗?

EDIT 编辑

The data variable is in this type: 数据变量具有以下类型:

var data = [[1348754599, 0.0], [1348754639, 0.0], [1348754680, 0.0], [1348754721, 0.0], [1348754761, 0.0], [1348754802, 0.0], [1348754842, 0.0], [1348754883, 0.0], [1348754924, 0.0], [1348754964, 0.0], [1348755005, 0.0], [1348755045, 0.0], [1348755086, 0.0], [1348755126, 0.0], [1348755167, 0.0], [1348755208, 0.0]];

Can you setup a fiddle for this, to clarify what you need? 您可以为此设置小提琴以澄清您的需求吗?

Update: Some corrections had to be made to the original fiddle, and the example uses the tablesorter jQuery plugin. 更新:必须对原始小提琴进行一些更正,并且该示例使用了tablesorter jQuery插件。 Here is the revised HTML to make it work: 这是经过修改的HTML,以使其正常工作:

<div class="container">
    <table class="table table-striped table-bordered table-condensed"></table>
</div>

and revised JavaScript: 和修订的JavaScript:

var data = [
    [1348754599, 0.0],
    [1348754639, 0.0],
    [1348754680, 0.0],
    [1348754721, 0.0],
    [1348754761, 0.0],
    [1348754802, 0.0],
    [1348754842, 0.0],
    [1348754883, 0.0],
    [1348754924, 0.0],
    [1348754964, 0.0],
    [1348755005, 0.0],
    [1348755045, 0.0],
    [1348755086, 0.0],
    [1348755126, 0.0],
    [1348755167, 0.0],
    [1348755208, 0.0]
];

$('table').html('<thead><tr><th>TIMESTAMP</th><th>VALUE</th></tr></thead><tbody></tbody>');

$.each(data, function (index, value) {
    $('table > tbody').append('<tr><td>' + index + '</td><td>' + value + '</td></tr>');
});

$(function () {
    $('table').tablesorter();
});

Here is a fiddle with a working example: http://jsfiddle.net/jkvr8/41/ 这是一个带有工作示例的小提琴: http : //jsfiddle.net/jkvr8/41/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM