首页 文章

Reactive-Tables Meteor

提问于
浏览
0

我试图让反应表工作,但我没有运气遵循GitHub上的说明 .

这就是我所拥有的:

在我的Main.html中:

{{> courseTable }}

在我的course_table.html中:

<template name="courseTable">
    <div id="table">
    {{ > reactiveTable collection=Courses}}
    </div>
</template>

在courses.js中:(适用于autoForm)

Courses = new Meteor.Collection("courses", {
    schema: {....

有什么我想念的吗?根据我的理解,一旦使用这些命令,其余的就在包内完成 . 我无法在任何地方找到关于此包的更多信息 .

我现在只是显示一个空白屏幕 .

提前致谢!

2 回答

  • 0

    这就是我所拥有的:(我正在使用Meteor框架和bootstrap-3包)

    在index.html中

    <template name="clientes">
        <div class="container">
            <div class="panel panel-primary">
                <div class="panel-heading">
                    <h3 class="panel-title">Clientes</h3>
                </div>
                <div class="panel-body">
                    {{> reactiveTable collection=tables settings=tableSettings}}
                </div>
            </div>
        </div>
    </template>
    

    在index.js中

    var Clientes = new Meteor.Collection('clientes')
    
    Template.clientes.tables = function () {
        return Clientes;
    }
    
    Template.clientes.tableSettings = function () {
        return {
            rowsPerPage: 10,
            showFilter: false,
            showNavigation: 'auto',
            fields: [
                { key: 'nombre', label: 'Nombre' },
                { key: 'apellido', label: 'Apellido' },
                { key: 'correoe', label: 'E-mail' }
            ],
            useFontAwesome: true,
            group: 'client'
        };
    }
    

    有了这个,我可以显示集合中的所有记录 . 我希望这可以帮助你继续前进 .

  • 3

    课程是集合对象 . 要获得一些课程,您需要使用find查询课程:

    Courses.find()
    

    但是,要在模板中访问它,您需要一个辅助函数 .

    //course_table.js
    Template.courseTable.helpers({
      courses: function () {
        return Courses.find()
      }
    });
    

    然后你可以使用helper方法设置表集合(为了清楚起见,我使用了一个小写的“课程”作为帮助方法):

    {{> reactiveTable collection=courses}}
    

相关问题