1
我如何設置datatables與Meteor Collection的數據源?如何設置datatables.net數據源在流星收藏?
我如何設置datatables與Meteor Collection的數據源?如何設置datatables.net數據源在流星收藏?
流星與C#/。NET有點不同。我不確定datatables顯式地從數組中獲取數據源/實際的數據變量。但是可以從最小的查詢中創建一個表,如People.find()
您有要轉換爲數據表的表。請與{{#each}}
循環基本表中的每個「行/文件」
<template name="data">
<table id="datatable">
<thead>
<th>Name</th>
<th>Address</th>
</thead>
<tbody>
{{#each person}}
<tr>
<td>{{name}}</td>
<td>{{address}}</td>
</tr>
{{/each}}
</tbody>
</table>
</template>
然後您將數據將它與連接到你的數據庫的模板助手:
Template.data.person = function() {
return People.find() //Return the data containing name/addresses of people
}
最後的東西轉換普通的普通表格到數據表
Template.data.rendered = function() {
$('#datatable').dataTable()
}
數據表實際上是Meteor項目的主要焦點,我用它來教授Meteor的基本知識。它在Github上:https://github.com/primigenus/meteor-bedenktijdje - 與Akshat的答案非常類似的代碼,但不需要數據表庫。 – Rahul 2013-03-27 17:20:18
@Rahul這是一個相當不錯的項目,我不是很流利的在荷蘭,所以你的學生可以實時提問,並且它彈出在屏幕上?這真的很酷 – Akshat 2013-03-27 17:26:38
無論它只是一個集合支持的人員列表,你可以進行表決和投票,並通過投票限制登錄狀態。 – Rahul 2013-03-27 17:33:54