1.0.0 • Published 8 years ago

ember-bootstrap-table v1.0.0

Weekly downloads
-
License
MIT
Repository
-
Last release
8 years ago

Ember-bootstrap-table

Table component built using Ember 2.5. It is built as ember component and available as ember-cli addon. It support both in memory operations and server side operations to support large data. it also allows you to handle very large data by only rendering the rows that are being displayed.

Supported features

Supports all features of Bootstrap Table with below additional features

  • Column sorting, both ascending and decending.
  • Default column sorting, sort table by a column when table is rendered
  • Free text filter, can be extended to add customised filter
  • Default filter is supported, filters table rows by default key when table is rendered
  • Navigation buttons, rendered using block content and hence can be customizable as needed
  • Row selection, single and multiple
  • Pagination, page size is configurable
  • Customizable as needed like to add action buttons in column cells, to highlight a row or a cell
  • Server side pagination, sorting and filtering

Dependencies

  • Ember 2.5.0
  • Ember-cli 2.5.0
  • Twitter Bootstrap 3.3.4, only CSS

Instalation

bower install ember-bootstrap-table --save

Developing or setting up this project on your computer

  • git clone https://github.com/radireddy/ember-bootstrap-table.git
  • npm install
  • bower install
  • bower install bootstrap

Running

Running Tests (no test cases added as of now)

  • npm test (Runs ember try:testall to test your addon against multiple Ember versions)
  • ember test
  • ember test --server

Building

  • ember build

Contributing

Interested in contributing to this addon, please contact me on adireddyravindra@gmail.com

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

Developer Guide

Usage

To create simple table, do following,

  • In your template use component as below

       {{#eb-table
            pageSize=10
            content=users
            columns=columns}}
        {{/eb-table}}
  • In your controller define columns and users array as below

    import Ember from 'ember';
    import ColumnDefinition from 'ember-bootstrap-table/models/column-definition';
    
    export default Ember.Controller.extend({
    
        users: [{firstName: 'James', lastName: 'Carter', age: 30},
                    {firstName: 'Steven', lastName: 'Smith', age: 35}]
    
        columns: Ember.computed(function() {
            var col1 = ColumnDefinition.create({
                header: 'First Name',
                isSortable: false,
                contentPath: 'firstName',
                isFilterable: true
            });
            var col2 = ColumnDefinition.create({
                header: 'Last Name',
                isSortable: false,
                contentPath: 'lastName',
                isFilterable: true
            });
            var col3 = ColumnDefinition.create({
                header: 'Age',
                isSortable: false,
                contentPath: 'age',
                textAlign: 'center',
                isFilterable: true
            });
            return [col1, col2, col3];
        })
    };
  • Table looks like this

Alt text

Table Options

Option NameRequiredDefault ValueDesctiption
contenttrueEmber.A()An array of row objects, or a promise that resolves to an array of row objects. Usually each row is a object where the keys are column names (column headers) and the values are the column values.
columnstrueEmber.A()An array of column definitions: see Column Definition options below. Allows each column to have its own configuration.
pageSizefalse10Positive integer, number of rows shown in each page depends on page size.
filterKeyfalse''String, used to filter rows. By default all columns value is matched with filterKey and row is shown only if any column value matches with filterKey. Whether to iclude column in filter or not can be configured using Column Defination shown below.
rowSelectionfalsenullCan be 'single' or 'multiple'.
rowSelectionHandlerfalsenullJavaScript function, call back funtion. This function will be called when a table row is selected or unselected. It passes array of rows selected as an argument. If no row is selected, array will be empty.
sortPropertiesfalse[]Array of colums that are sorted. This can be used to supplay default column sort to table. For example 'firstName:asc' will sort table data by First Name column in ascending order when table is rendered. 'firstName:desc' with sort in descending order.
emptyMessagefalseNo records foundString, this message is shown when there are no rows in table.
loadingMessagefalseLoading...String, this message is shown when data is fetched from server.
responsiveTablefalsetrueBoolean, if true adds bootstrap 'table-responsive' class to table. Makes table responsive. For more info http://getbootstrap.com/css/#tables-responsive
condensedTablefalsefalseBoolean, if true adds bootstrap 'table-condensed' class to table. Reduces table row height. For more info http://getbootstrap.com/css/#tables-condensed
borderedTablefalsetrueBoolean, if true adds bootstrap 'table-bordered' class to table. Adds border to table, for more info http://getbootstrap.com/css/#tables-bordered
nowrapTablefalsetrueBoolean, if true adds bootstrap 'table-nowrap' class to table. If falsewraps cell content if it exceds available width.
tableStripedfalsefalseBoolean, if true adds bootstrap 'table-striped' class to table. Adds zebra-striping to table rows. For more info http://getbootstrap.com/css/#tables-striped
rowComponentNamefalseeb-table-rowString, table row component name. If you need to customize table row (for ex: if you need to highlight row on certain condition), extend eb-table-row to add your own extension logic and then provide extended component name through this property.

Column Options

Column options are passed to table as an array of 'column-definition' model. Each column need to extend 'column-definition' model and override column options if required.

Option NameRequiredDefault ValueDesctiption
headertruenullString, Column header.
contentPathtruenullString, row key name. It should exactly match with key name of an object. This property will be used to get value from object.
isSortablefalsefalseBoolean, if true, sorting is enabled on this column.
isFilterablefalsetrueBoolean, if true, filter is enabled on this column.
textAlignfalse'left'String, column align order. Available options are 'left', 'right' and 'center'
widthfalsenullString, column width ex: '100px'. If no width is provided, no width is mentioned on column.
isSortedfalsefalseBoolean, used to indicate default column sort on table column header. If true sort order icon appears on table column header. Use table 'sortProperties' option to enable default sort.
sortOrderfalse'asc'String, used to indicate default column sort order on table column header. Up or down icon appears on table column header. Use table 'sortProperties' option to enable default sort.
columnComponentNamefalseeb-table-columnString, table column component name. If you need to customize table column (for ex: if you need to highlight column cell on certain condition), extend eb-table-column to add your own extension logic and then provide extended component name through this property.
hidefalsefalseBoolean, if true, hids column from table. This can be used if u dont want to show column on table but need to filter rows based on this column.

Remote Table Options

All options mentioned above are applicable along with some additional options mentioned below.

Option NameRequiredDefault ValueDesctiption
totalRecordstrue0Positive integer, total number of records found in DB. Exact value is required for pagination to work properly.
dataFetchHandlertruenullJavaScript function, call back function. Table depends on this function to get data. Table calls this method when ever new data is required, on sorting, pagination, filteretc. It passes current page, page size, sort property, sort order and filter key as arguments.

Table images

Alt text

Alt text

Alt text

Alt text

Alt text

Alt text

Alt text

Alt text