0.3.11 • Published 7 years ago

ember-imdt-table v0.3.11

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

Ember-imdt-table

This is an Ember Table Component inspired on Ember-models-table: https://github.com/onechiporenko/ember-models-table

Installation

  • git clone this repository
  • npm install
  • bower install

Usage

First set your content up, here we are using a predefined json as the content, but you can use your model aswell.

// ../controllers/index.js
values = [
  {
    "id":1,
    "firstName":"Kiana",
    "lastName":"Murphy",
    "age":19,
    "city":"Lahore",
    "cityWithHtml":"<i>Lahore</i>"},
  {
    "id":2,
    "firstName":"Ingeborg",
    "lastName":"Jones",
    "age":48,
    "city":"Tianjin",
    "cityWithHtml":"<i>Tianjin</i>"},
  {
    "id":3,
    "firstName":"Chuck",
    "lastName":"Ali",
    "age":32,
    "city":"Bogotá",
    "cityWithHtml":"<i>Bogotá</i>"},
  {
    "id":4,
    "firstName":"Chasity",
    "lastName":"Quinn",
    "age":36,
    "city":"Cairo",
    "cityWithHtml":"<i>Cairo</i>"},
  {
    "id":5,
    "firstName":"Chuck",
    "lastName":"Taylor",
    "age":44,
    "city":"Lahore",
    "cityWithHtml":"<i>Lahore</i>"
  }
];

Then set up the table properties,

// ../controllers/index.js

content: values,
columns: new A([{
  contentPath: 'id',
  columnTitle: 'ID',
  isSortable: false,
  isSearchable: false,
}, {
  contentPath: 'firstName',
  columnTitle: 'First Name'
}, {
  contentPath: 'lastName',
  columnTitle: 'Last Name'
}, {
  contentPath: 'cityWithHtml',
  columnTitle: 'City',
  sortPath: 'city'
},
{
  contentPath: 'age',
  columnTitle: 'Age'
},

After you have everything set up, all you need to do is use the table helper on your template and pass your defined properties as parameters, along with more options:

<!-- ../templates/index.hbs -->

{{imdt-table
  content=content
  columns=columns
  sortProperties=sort
  paginable=true
  searchable=true
  sortable=true
}}

If you want to set some sort properties for the table to be sorted on load you can do it, like this:

sort: new A(['city:desc', 'firstName:desc', 'lastName:asc']),

Supported Properties

propertydescriptiondefault
contentcontent that will be displayed in the table cellsnull
columnscolumn configuration and namesnull
sortPropertiessort properties on loadnull
paginablewhether the table has pagination or notfalse
searchablewhether the table has search or notfalse
sortablewhether the table is sortable or notfalse
useSimplePaginationwhether the page has simple pagination or numbered paginationtrue

Rendering templates on column

If you want to render a custom template inside a table cell, like a button, checkbox, or wathever else you would need you can do it by adding the column that will render the template in your column configuration, like this:

// ../controllers/index.js

columns: new A([{
    contentPath: 'id',
    columnTitle: 'ID',
    isSortable: false,
    isSearchable: false,
  }, {
    contentPath: 'firstName',
    columnTitle: 'First Name'
  }, {
    contentPath: 'lastName',
    columnTitle: 'Last Name'
  }, {
    contentPath: 'cityWithHtml',
    columnTitle: 'City',
    sortPath: 'city'
  },
  {
    contentPath: 'age',
    columnTitle: 'Age'
  },
  {
    contentPath: 'template',
    columnTitle: 'Template',
    template: 'custom/button'
  }

...

Running

0.3.11

7 years ago

0.3.10

7 years ago

0.3.9

7 years ago

0.3.8

7 years ago

0.3.7

7 years ago

0.3.6

7 years ago

0.3.5

7 years ago

0.3.4

7 years ago

0.3.3

7 years ago

0.3.2

8 years ago

0.3.1

8 years ago

0.3.0

8 years ago

0.2.21

8 years ago

0.2.20

8 years ago

0.2.19

8 years ago

0.2.16

8 years ago

0.2.15

8 years ago

0.2.14

8 years ago

0.2.13

8 years ago

0.2.11

8 years ago

0.2.10

8 years ago

0.2.9

8 years ago

0.2.8

8 years ago

0.2.7

8 years ago

0.2.6

8 years ago

0.2.5

8 years ago

0.2.4

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.17

8 years ago

0.1.16

8 years ago

0.1.15

8 years ago

0.1.14

8 years ago

0.1.13

8 years ago

0.1.12

8 years ago

0.1.11

8 years ago

0.1.10

8 years ago

0.1.9

8 years ago

0.1.8

8 years ago

0.1.7

8 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.4

8 years ago

0.1.3

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.0

8 years ago