0.3.1 • Published 10 years ago

ember-cli-ember-table v0.3.1

Weekly downloads
2
License
MIT
Repository
-
Last release
10 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

10 years ago

0.3.0

10 years ago

0.2.4

10 years ago

0.2.3

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

11 years ago

0.0.4

11 years ago

0.0.3

11 years ago

0.0.2

11 years ago

0.0.1

11 years ago