0.3.1 • Published 9 years ago

ember-cli-ember-table v0.3.1

Weekly downloads
2
License
MIT
Repository
-
Last release
9 years ago

ember-cli-ember-table

NOTE: This addon is a fork from http://addepar.github.io/ember-table into vanilla JS and ES6 style modules. The fork was made out of the master branch @ea0983f.

Test in dummy app locally

  • git clone this repository
  • cd ember-cli-ember-table
  • npm install
  • bower install
  • ember server
  • Visit http://localhost:4200

Usage (in consuming ember-cli project)

  • npm install ember-cli-ember-table --save
  • ember g ember-cli-ember-table

At this point you can use the component in the templates of your consuming app.

{{ember-table
  height=400
  hasFooter=false
  enableContentSelection=true
  columnsBinding="columns"
  contentBinding="content"
}}

You will also need to setup your controller to provide content for the ember-table.

Example controller

import ColumnDefinition from '../column-definition';

export default Ember.Controller.extend({
  numRows: 10000,

  columns: function() {
    var dateColumn, openColumn, highColumn, lowColumn, closeColumn;
    dateColumn = ColumnDefinition.create({
      columnWidth: 150,
      textAlign: 'text-align-left',
      headerCellName: 'Date',
      getCellContent: function(row) {
        return row.get('date').toDateString();
      }
    });
    openColumn = ColumnDefinition.create({
      columnWidth: 100,
      headerCellName: 'Open',
      getCellContent: function(row) {
        return row.get('open').toFixed(2);
      }
    });
    highColumn = ColumnDefinition.create({
      columnWidth: 100,
      headerCellName: 'High',
      getCellContent: function(row) {
        return row.get('high').toFixed(2);
      }
    });
    lowColumn = ColumnDefinition.create({
      columnWidth: 100,
      headerCellName: 'Low',
      getCellContent: function(row) {
        return row.get('low').toFixed(2);
      }
    });
    closeColumn = ColumnDefinition.create({
      columnWidth: 100,
      headerCellName: 'Close',
      getCellContent: function(row) {
        return row.get('close').toFixed(2);
      }
    });
    return [dateColumn, openColumn, highColumn, lowColumn, closeColumn];
  }.property(),

  content: function() {
    var generatedContent = [];
    for (var i = 0; i < this.get('numRows'); i++) {
      var date = new Date();
      date.setDate(date.getDate() + i);
      generatedContent.push(Ember.Object.create({
        date: date,
        open:  Math.random() * 100,
        high:  Math.random() * 100 + 50,
        low:   Math.random() * 100 - 50,
        close: Math.random() * 100
      }));
    }
    return generatedContent;
  }.property('numRows'),
...

For more information on how to setup ember-table, please visit http://addepar.github.io/ember-table.

For more information on using ember-cli, please visit http://www.ember-cli.com/.

0.3.1

9 years ago

0.3.0

9 years ago

0.2.4

9 years ago

0.2.3

9 years ago

0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.9

9 years ago

0.0.8

9 years ago

0.0.7

9 years ago

0.0.6

9 years ago

0.0.5

9 years ago

0.0.4

9 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago