Giter Club home page Giter Club logo

sematable's Introduction

Sematable

No Maintenance Intended

⛔️ DEPRECATED This repository isn't mantained by Sematext any more.

Sematable wraps a table component, and provides:

  • filtering by column value
  • search with text
  • sorting
  • row selection
  • pagination

... with the ability to persist the table state in application state with Redux, so filters, sort info, selected rows, and pagination info survives route navigations.

image

⚠ CSS Dependencies

Sematable assumes that Bootstrap CSS, Font Awesome CSS, and react-select CSS are already loaded, so please make sure that's the case. Sematable should work with either Bootstrap 3 or Bootstrap 4. You can find the css for react-select in node_modules/react-select/dist/react-select.css.

Reducer

Before using the sematable wrapper, you need to setup the reducer. You should combine the provided reducer in your root reducer like this:

import { reducer as sematable } from 'sematable';

const reducer = combineReducers({
  sematable,
  ...
});

Usage

The most frequent use case for sematable is to show tabular data with some actions (edit, delete, etc.). See the below example for that.

For information on how to get selected rows and other table state, check out the section about selectors.

AppsTable.js:

import React, { Component, PropTypes } from 'react';
import sematable, { Table } from 'sematable';
import AppsTableActions from './AppsTableActions';

const columns = [
  { key: 'id', header: 'ID', sortable: true, searchable: true, primaryKey: true },
  { key: 'name', header: 'Application', sortable: true, searchable: true },
  { key: 'token', header: 'Token' },
  { key: 'plan', header: 'Plan', sortable: true },
  { key: 'role', header: 'Role', sortable: true },
  { key: 'actions', header: 'Actions', Component: AppsTableActions },
];

const propTypes = {
  headers: PropTypes.object.isRequired,
  data: PropTypes.array.isRequired,
  primaryKey: PropTypes.string.isRequired,
};

class AppsTable extends Component {
  render() {
    return (
      <Table
        {...this.props}
        selectable
        columns={columns}
      />
    );
  }
}

AppsTable.propTypes = propTypes;
export default sematable('allApps', AppsTable, columns);

AppsTableActions.js:

import React, { Component, PropTypes } from 'react';
import { Link } from 'react-router';

const propTypes = {
  row: PropTypes.object.isRequired,
};

class AppsTableActions extends Component {
  render() {
    const row = this.props.row;
    return (
      <Link to={`/settings/${row.id}`}>
        Settings
      </Link>
    );
  }
}
AppsTableActions.propTypes = propTypes;
export default AppsTableActions;

The sematable function will wrap your component and add filter, pagination, and other sematable functionality. The first argument is name of this table. It should be unique across your app. The second argument is your component, and the third are the column definitions.

  • You can omit the selectable property to hide the row selection controls.
  • You can use the className property to set the table class (table-sm table-striped table-hover is the default).

Columns definitions have the following properties:

  • key is the name of the property used in row objects
  • header is the header label that will be used for this column
  • title is the title that will be used when column header is hovered
  • className is the css class to use for the column <td> element
  • sortable defines if user should be able to sort by this column
  • searchable defines if user should be able to text-search by this column (simple case-insensitive substring search)
  • primaryKey defines if this column is the primary key
  • hidden defines if we should hide this column (useful if you don't want to show primary key column)
  • Component defines which component should be used to render cell contents
  • filterable defines if user should be able to filter rows by distinct values of this column
  • filterValues can be provided to define distinct filter values for this column. If not provided, unique values will be extracted from provided data.
  • getFilterTitle is a function with (value) signature that can be provided to customize the filter title
  • getFilterLabel is a function with (value) signature that can be provided to customize the filter label
  • getFilterClassName is a function with (value) signature that can be provided to customize the filter css class

At least one column definition should have primaryKey: true.

Check out stories/UsersTable.js to see how these properties can be used.

Advanced Usage

If you just need to show tabular data, with some actions for each row, you can use the provided Table component in combination with the sematable wrapper as shown above. Otherwise, you can write the table structure yourself.

The sematable(tableName, component, columns, configs) wrapper accepts four parameters:

  • tableName is a unique name for this table (used to store state)
  • component is the table component you want to wrap
  • columns is an array of column definitions
  • configs is an optional object where you can specify configuration properties

Showing page size and filter somewhere else

If you want to show the page size and filter somewhere else in your application, you can use the provided PageSizeContainer, and FilterContainer component. Like this:

import { PageSizeContainer, FilterContainer } from 'sematable';

export default props => (
    <div>
      <FilterContainer tableName="myTable" />
      <PageSizeContainer tableName="myTable" />
    </div>
);

You can style these components with style or className.

Configuration properties:

  • plain if you want only the table component to be returned without page size, pagination, or filter (will not use bootstrap grid)
  • showPageSize if page size select should be shown
  • showFilter if text filter field should be shown
  • defaultPageSize overrides the default page size (if not specified 5 will be used)
  • autoHidePagination if pagination should be hidden if the number of pages is 1 (default is true, which means pagination is hidden if the number of pages is equal to 1)
  • filterClassName css class for the filter component
  • filterClassNamePrefix css class prefix forwarded to react-select ('Select' by default)
  • filterContainerClassName css class for the filter component container element ('col-md-6' by default)
  • filterPlaceholder filter placeholder text
  • pageSizeClassName css class for the page size component ('col-md-6' by default)
  • pageSizeContainerClassName css class for the page size component container element ('col-md-6' by default)
  • sortKey default column to sort by (not sorted by default)
  • sortDirection default sort direction, asc or desc (asc by default)

There's no requirement that the wrapped component needs to be a table, it could be a list, a div, an image gallery, or anything else.

We will pass the following props to the wrapped component:

  • data is the filtered, sorted, and paginated data (the current view)
  • headers contains callbacks for sorting and selection
  • primaryKey is the name of the primary key field

Here's how you would implement the same example shown above without the provided Table component.

AppsTable.js:

import React, { Component, PropTypes } from 'react';
import { Link } from 'react-router';
import sematable, {
  SortableHeader,
  SelectAllHeader,
  SelectRow,
} from 'sematable';

const columns = [
  { key: 'id', header: 'ID', searchable: true, sortable: true, primaryKey: true },
  { key: 'name', header: 'Name', searchable: true, sortable: true },
];

const propTypes = {
  headers: PropTypes.object.isRequired,
  data: PropTypes.array.isRequired,
};

class AppsTable extends Component {
  render() {
    const {
      headers: { select, id, name },
      data,
    } = this.props;
    return (
      <div className="table-responsive">
        <table className="table table-sm table-striped table-hover">
          <thead>
            <tr>
              <SelectAllHeader {...select} />
              <SortableHeader {...id} />
              <SortableHeader {...name} />
              <th>Actions</th>
            </tr>
          </thead>
          <tbody>
            {data.map((app) => (
              <tr
                key={app.id}
                className={`${select.isSelected(app) ? 'table-info' : ''}`}
              >
                <td>
                  <SelectRow row={app} {...select} />
                </td>
                <td>{app.id}</td>
                <td>{app.name}</td>
                <td>
                  <Link to={`/settings/${app.id}`}>
                    Settings
                  </Link>
                </td>
              </tr>
            ))}
          </tbody>
        </table>
      </div>
    );
  }
}

AppsTable.propTypes = propTypes;
export default sematable('allApps', AppsTable, columns);

Selectors

We provide a few selectors that can be useful when working with sematable:

getSelectedRows
getInitialData
getIsInitialized
getFiltered
getFilter
getFilterText
getColumns
getSortInfo
getPageInfo
getVisible
getSelectAll
getPrimaryKey

These are exposed with makeSelectors(tableName). You should use them like this:

import { makeSelectors } from 'sematable';

const selectors = makeSelectors('myTable');
const mapStateToProps = (state) => ({
  selectedRows: selectors.getSelectedRows(state)
});

Actions

You can use the below actions to alter the state of the table:

  • tableDestroyState(tableName) resets/destroys the current state of the table. This can be used in componentWillUnmount() to reset the related redux state.
  • tableSetFilter(tableName, filterValue) sets the table filters where filterValue is an array of filter objects.

You can import actions from the sematable module like this:

import { tableDestroyState } from 'sematable';

Filters

You can set the list of filters by passing filterValue to your sematable component, or by using the tableSetFilter action. In either case, the provided value should be an array of two types of objects:

  • text filter defined simply as a string
  • value filter defined as object with properties key and value, where key is the column key you want to filter, and value is the value you want to filter by.

For example:

<UsersTable
  data={users}
  filterValue={[
    'Bob',
    { key: 'confirmed', value: true },
  ]}
/>

Or with tableSetFilter:

dispatch(tableSetFilter('usersTable', [
  'Bob',
  { key: 'confirmed', value: true },
]));

Custom components

CheckboxComponent for SelectAllHeader, accepting properties

{
  onChange: PropTypes.func,
  checked: PropTypes.bool,
  disabled: PropTypes.bool,
  children: PropTypes.node,
  className: PropTypes.string,
  id: PropTypes.string,
}

NoDataComponent for rendering custom messages when there is no data available, accepting properties:

{
  filter: PropTypes.array // List of applied filters for table
}

sematable's People

Contributors

amir-hadzic avatar blacktemplar avatar dependabot[bot] avatar gor181 avatar hamer86 avatar headwinds avatar jonicious avatar lujomon avatar mbonaci avatar obee88 avatar otisg avatar prog8 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sematable's Issues

no default way of displaying the search filter unless using Table component?

After my experimentation with the 'advanced usage' instructions, I am able to produce the following table using reactstrap (Bootstrap 4 components):

sematable

However, the problem seems to be that the search/filter component is not displaying appropriately. Note that I have not defined any particular filters, but it would be nice to get the text search behavior though (I've defined some of the columns as 'searchable'), but I am not sure how, given that I am not using the sematable 'Table' component. Any suggestions?

Provide function to AppsTableActions cell

Hi, I want to ask how you resolve case when we must provide function to action cell?

class AppsTableActions extends Component {
  render() {
    const { row, onRmove } = this.props;
    return (
      <button onClick={() => onRmove(row.id)}>
        Remove
      </button>
    );
  }
}

For now I have two idea. First is use redux connect() to provide action creator to AppsTableActions. Second is generate columns by function and bind actions in component constructor:

const pepareCol = ({ onRemove }) => [
  {
    key: 'id',
    header: 'id',
  },
  {
    key: 'action',
    header: 'edit',
    Component: (props) => <ActionsCell {...props} onRemove={onRemove} />,
  },
];

  constructor(props) {
    super(props);
    this.columns = pepareCol({
      onRemove: props.removeEntity,
    });
  }

But maybe exists better solution?

can 'sortKey' be a function?

I'm wondering if I can pass a function as the value of 'sortKey' when defining my headers object. In my use case, I need to sort one of the columns based on a value calculated from a couple of fields in each of the objects. Having 'sortKey' as a function would allow me to not have to redundantly define a property for my data that is calculated based on the value of other existent properties.

Error when data is undefined/null

I'm getting Cannot read property 'forEach' of undefined , I may still have missed something, reducer is working fine, this an example of the code:

import React from 'react'
import PropTypes from 'prop-types'
import sematable, {
  SortableHeader,
  SelectAllHeader,
  SelectRow,
} from 'sematable'

const columns = [
  { key: 'id', header: 'ID', searchable: true, sortable: true, primaryKey: true },
  { key: 'inserted_at', header: 'Name', searchable: true, sortable: true },
]

const Invoices = ({ invoices, getInvoices, headers: { select, id, name } }) =>  (
    <div>
      <button onClick={getInvoices}>Actualizar</button>
      {invoices.length > 0 &&
      <table>
        <thead>
          <tr>
            <SelectAllHeader {...select} />
            <SortableHeader {...id} />
            <SortableHeader {...inserted_at} />
            <th>Actions</th>
          </tr>
        </thead>
        <tbody>
          {invoices.map(invoice => (
            <tr
              key={invoice.id}
            >
              <td>{invoice.id}</td>
              <td>{invoice.inserted_at}</td>
            </tr>
          ))}
        </tbody>
      </table>}
    </div>
)

Invoices.propTypes = {
  invoices: PropTypes.array,
  getInvoices: PropTypes.func
}

export default sematable ( 'allApps', Invoices, columns )

Custom properties for components?

Is there a way to send properties to the custom components ?

I have multiple tables, and would like to reuse the custom components, but the data fields names are not always the same, and would like to keep the data untouched.

Thanks

Possible to add available actions?

First of all, wanted to say thanks for the awesome job so far. This project is a huge boon for table utility in the React/Redux space. Just wanted to ask - are you guys open to exposing more Sematable actions for use in connected components?

For example, I just ran into a need for using the 'tableSelectAllChanged' action but had to manually adjust the index.js file, whereas the tableDestroyState and tableSetFilter actions seem to be the only ones currently available by default.

Add an online demo?

Could you add an online demo/example so that one could play with sematable without having to download and run it? It would make it easier for people to see how awesome sematable is :).

Text Search not working

If I have the following table
| hello | hi |
and I search with hello, hi i will not get any results because the selector code below uses _.every

return _.every(textFilters, f => normalized.indexOf(f) > -1);

which will only return true if both hello & hi are present in single column.

How to make table headers translatable?

Hey there,

I've created my own translation HOC, and I'm looking to make it work with Sematable.

I've worked on 3 ideas but have been unable to make it work.

  1. I'm trying to pass my props to the columns array, transforming columns into function and thus having to override the PropTypes definition within your Framework throught the columns variable.

  2. My second approach is to read this translation directly from LocalStorage. However, the difficulty that I encounter here is that I refresh the page in order for the change to be reflected. How could I manually destroy a specific table, or better yet in my case, all the tables ?

  3. My last idea would be based on the advanced example in your GitHub Readme... However, to pursue this idea further I would find it extremely helpful if you could explicitely show me the code for headers: { select, id, name } which is passed as props to AppsTable.

import React, { Component, PropTypes } from 'react';
import sematable, { Table } from 'sematable';
import AppsTableActions from './AppsTableActions';

const columns = [
  { key: 'id', header: 'ID', sortable: true, searchable: true, primaryKey: true },
  { key: 'name', header: 'Application', sortable: true, searchable: true },
  { key: 'token', header: 'Token' },
  { key: 'plan', header: 'Plan', sortable: true },
  { key: 'role', header: 'Role', sortable: true },
  { key: 'actions', header: 'Actions', Component: AppsTableActions },
];

const propTypes = {
  headers: PropTypes.object.isRequired,
  data: PropTypes.array.isRequired,
  primaryKey: PropTypes.string.isRequired,
};

class AppsTable extends Component {
  render() {
    return (
      <Table
        {...this.props}
        selectable
        columns={columns}
      />
    );
  }
}

Any help would be truely appreciated.
Thank you so much!

filtering by column works from the code but not in the browser

i noticed that when i set the filter from my code this way :
<Table data={data} filterValue={[ { key: 'owner', value: 'essam' } ]} />

i can see owner:essam in the search box in the table and it filters my data correctly
but if i type owner:essam manually, it doesnt work , just pops out "There is no data available
"

allApps undefined

Sorry I am new to Javascript/React/Redux and must be missing something here. I am trying the very basic example provided in documentation, but when I try to run it it throws this error. Not sure what am I missing here? I have the reducer included in my global reducers.
Error

selectors.js:128 Uncaught TypeError: Cannot read property 'allApps' of undefined
    at Object.getIsInitialized (selectors.js:128)
    at mapStateToProps (sematable.js:95)
    at Connect.configureFinalMapState (connect.js:155)
    at Connect.computeStateProps (connect.js:142)
    at Connect.updateStatePropsIfNeeded (connect.js:204)
    at Connect.render (connect.js:340)
    at ReactCompositeComponent.js:796
    at measureLifeCyclePerf (ReactCompositeComponent.js:75)
    at ReactCompositeComponentWrapper._renderValidatedComponentWithoutOwnerOrContext (ReactCompositeComponent.js:795)
    at ReactCompositeComponentWrapper._renderValidatedComponent (ReactCompositeComponent.js:822)

Code

const columns = [
    { key: 'id', header: 'ID', sortable: true, searchable: true, primaryKey: true },
    { key: 'name', header: 'Application', sortable: true, searchable: true },
    { key: 'token', header: 'Token' },
    { key: 'plan', header: 'Plan', sortable: true },
    { key: 'role', header: 'Role', sortable: true },
    { key: 'actions', header: 'Actions', Component: AppsTableActions },
];

const propTypes = {
    headers: PropTypes.object.isRequired,
    data: PropTypes.array.isRequired,
    primaryKey: PropTypes.string.isRequired,
};



class AppsTableActions extends React.Component {
    render() {
        const row = this.props.row;
        return (
            <Link to={`/settings/${row.id}`}>
                Settings
            </Link>
        );
    }
}

AppsTableActions.propTypes = {
    row: PropTypes.object.isRequired,
};

class GroupGrid extends React.Component {

    breadcrumbs() {
        return [
            {
                icon: 'fa-users',
                title: 'Home'
            },
            {
                title: 'Groups',
                active: true
            }
        ];
    }


    actionButtons() {
        return [
            {
                'type': 'link',
                'label': 'New',
                'className': 'btn-primary',
                'path': '/frontend/group/new'
            }
        ]
    }

    render() {



        return (
            <Content title="Group Management" breadcrumbs={this.breadcrumbs()}>
                <Table
                    {...this.props}
                    selectable
                    columns={columns}
                />
            </Content>
        );
    }
}

GroupGrid.propTypes = propTypes;
export default sematable('allApps', GroupGrid, columns);

custom styling of container classes breaks behavior of page size + search components

I noticed that with custom settings for the page size + filter containers - to ensure that the pagesize + search are displayed in the same row- (e.g. col-xs-6 instead of 'col-md-6', which is the default ), and at certain window widths, the table itself does not show up (it does show at xs width, md and lg, but apparently not in between). After looking at the source I realized that the TableComponent and Pagination components always use a 'col-md-12' for their respective containers. Does this explain the behavior I'm seeing? And if so, could a custom classname (configuration) for the table + pagination components resolve it?

An update on this after looking even more closely: I've noticed that all the components in the sematable (pagesize, filter, table and pagination components) are being rendered in the same row, and I wonder whether this is the real cause of the behavior I mention above. If so, possibly switching your render to using 3 rows instead (1 for the page size + filter, 1 for the table, 1 for the pagination) could resolve it, even if you did not add any extra configuration options?

NOTE: I am using Bootstrap 3

UPDATE on 5/1/2017:
The symptoms for this problem have now changed. When I use custom container styling for the page size + search components (with either 'col-xs-6' or 'col-sm-6'), I now see their respective behaviors broken (both page size + search display but do not work at all) when the window size is reduced. Note: I am using version 1.4.4 of sematable.

How to integrate custom components?

Hey,

really like this solution, especially because it is fully integrated into the Redux state. Also like your approach for selectors for the parent component to e.g. get all selected rows. The following is not really an issue with the project, more like a question. Not sure if it's the best place to ask them. Excuse me if it is not.

In my project, I already have many custom components that basically look pretty similar to TableRow, Table, SelectRow and Pagination. Also, I am having reducers that handle all the pagination actions but the code grew and grew and needs some refactoring. sematable does have the exact functionality I need and could replace my current reducers. Therefore, I would like to refactor my table components to use sematable.

While playing around a little with sematable, I noticed it relies heavily on the given components and you really can just set the TableComponent as second param when "initiating" sematable. You can just set showPageSize and showFilter to false. Sadly, there is no option to hide the pagination.

So.. what is the best option to just use the Redux part of sematable and integrate custom components?

Thanks in advance for your help!

problem trying to use Sematable

sematable-master.zip
sematable-master.zip

Hello
I am trying to use Sematable but I got the next error:

npm run storybook

[email protected] storybook C:\Users\jcabrerazuniga\Documents\play\sematable-master
BOOTSTRAP_VERSION=4.0.0 start-storybook -p 6006

'BOOTSTRAP_VERSION' is not recognized as an internal or external command,
operable program or batch file.

npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "run" "storybook"
npm ERR! node v6.10.0
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! [email protected] storybook: BOOTSTRAP_VERSION=4.0.0 start-storybook -p 6006
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] storybook script 'BOOTSTRAP_VERSION=4.0.0 start-storybook -p 6006'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the sematable package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! BOOTSTRAP_VERSION=4.0.0 start-storybook -p 6006
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs sematable
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls sematable
npm ERR! There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\jcabrerazuniga\Documents\play\sematable-master.storybook\npm-debug.log

I was able to get all the node related modules to compile the js programs and a lib folder was created with "normal" java script files. Yet, I can't run your sample.

Can you please give me an idea about what/how this is happening?

Sematable filter seems case (in)sensitive

It seems that it matches results only if filtering term is entered lowercased even if column value is mixed case.
There should be property to determine if filtering should be case sensitive and by default it should be fully case insensitive.

header tooltips are not working

Sorry for creating a new issue on this. Not sure whether you are following comments on closed issues (issue #24), so I decided to create a new one. But feel free to merge this issue into the other one if appropriate. As I explained there, the fix you had applied a week ago did not work for me. Please see my comments in (now closed) issue #24.

page size choice not displaying correctly when 'All' is chosen

I've noticed that when changing the table's size to show 'All' of the elements, the display reads 'All false somenumber' , instead of the expected 'All of somenumber'. In other words, the 'of' word seems to be replaced incorrectly by 'false' when choosing the 'All' option (all other options display 'of' instead).

header tooltip styling (2 related issues)

Hi, now that I've seen the header tooltips working, I realize that the styling is different than that I use throughout my app for tooltips (Bootstrap 3). Is there any way that I could choose to use the same styling for the header tooltips?

In addition, how do I give a tooltip to a header that I am rendering myself? Note that I am not using the Table element provided by sematable; I am rendering the table myself (advanced usage, according to the documentation). While most of my headers are Sematable headers, I have a couple which are not, so I simply render them using

    <th><some label></th>. 

UPDATE: I've already figured out the answer to the second paragraph above. I've managed to do it using the following:

<th data-toggle="tooltip" style={{ cursor: 'pointer', }}><some label></th>

Make possible to distinguish between 'loading' and 'no-data-returned'

I used spinning wheel as NoDataComponent and it works well, but the issue is that it shows whenever there is no data, even when the back end returns empty array or search doesn't find any docs.
So we would need to have both NoDataComponent and LoadingComponent.
FYI I can implement this (I need it right away).
If I missed something here please provide feedback.
Thx.

Add support for tags in filters

User must be able to filter the table by selecting predefined tags in the filter. By default, the tags must be generated from the provided data by taking unique values for each column that is marked as taggable.

The tags must be auto-completed while user is typing, and the tags should be displayed in the form of "ColumnName:TagValue".

  • User must still be able to use the filter for free form text search.
  • Developer must specify that a column is taggable by setting taggable: true in the column definition.
  • Developer must be able to programmatically add or remove tags from the filter.
  • Developer should be able to override the available tags for each column by defining tags: ['value1', 'value2'] in the column definition.
  • Developer should be able to provide a class name for each distinct tag value so it's possible to customize how the tag is displayed in the filter dropdown.

Showing Incorrect page size

If there are only 10 items in the table and if we select pageSize as 50 it is showing 50 of 10 which is incorrect

expected behaviour:
if the selected page size is less than filtered page size show the filteresd page size.
screen shot 2017-12-13 at 1 46 54 pm

Getting Filtered Data

Is there GetFilteredData Selector that I can use to get the search result after applying a filter. GetVisible is only giving the first Page. I am adding Download as excel option so If the user is filtering the data the download should only have Filtered values.

Error when using sematable with server-side rendering

I am including the example AppsTable in a component like so:

return ( ... <AppsTable data={apps} /> ... )

And I can't for the life of me figure out why this is wrong. The server-rendered version is spit out and doesn't contain the table because it renders before AppsTable is initialized (I think). The client-side eventually does render the table and it works, but its not-equal to the server-rendered version and so react/redux throws and error complaining about the difference.

I guess I am not including the table correctly. Could you please point out how it should be done?

Passing props to actions component

I am trying to pass an action to the GroupActions component, but not sure how is it doable here. I have a container component which is decorated by redux connect with bindActionCreators. Here is how it looks.

   <GroupPage>
        <GroupTable />
   </GroupPage>

And this my GroupTable

export const GROUP_TABLE = 'groupsTable';
const columns = [
    { key: 'id', header: 'ID', sortable: true, primaryKey: true },
    { key: 'name', header: 'Name', sortable: true, searchable: true },
    { key: 'actions', header: 'Actions', Component: GroupTableActions },
];

class GroupTable extends React.Component {
    render() {
        return (<Table {...this.props} columns={columns}  />);
    }
}

export default sematable(GROUP_TABLE, GroupTable, columns);

Here it renders GroupTableActions in GroupTable component, which looks like this.

class GroupTableActions extends React.Component {

    constructor(props) {
        super(props)
        this.handleDeleteGroup = this.handleDeleteGroup.bind(this);
    }

    handleDeleteGroup() {
        this.props.deleteGroup(this.props.row.id);
    }

    render() {
        const row = this.props.row;
        console.log(this.props.deleteGroup);
        return (
            <div className="btn-group">
                <button type="button" className="btn btn-default dropdown-toggle" data-toggle="dropdown"
                        aria-expanded="false">
                    ...
                    <span className="sr-only">Toggle Dropdown</span>
                </button>
                <ul className="dropdown-menu" role="menu">
                    <li>
                        <Link to={`/frontend/group/edit/${row.id}`} onClick={this.handleDeleteGroup}>
                            Edit
                        </Link>
                    </li>
                    <li>
                        <Link to={`/frontend/delete/${row.id}`}>
                            Delete
                        </Link>
                    </li>
                </ul>
            </div>

        );
    }
}
export default GroupTableActions;

What I want here is when delete on each item in the table is clicked, I want to dispatch the deleteGroup action. But I am not sure how can I pass my actions from parent component (GroupPage />) to the GroupActions component ?

Add support for multiple primaryKey columns

Based on discussion in #68, it might be a good idea to add support for multiple primaryKey columns. From user's perspective, they would be able to mark multiple columns as primaryKey: true, and we would then use the combined value from those columns as the composite key.

No table properties in Component context

When I use Component to render cell I'd like to add table-level properties. Today there is no option to do this. I can only add additional field to row. This is not good if I have to add the same object to each row (flatten structure).

Table without Primary key

My table have composite key, is there an api available which will accept a function to generate primaryKey from the given data, Or automatically take the index as the primary key?

Need one example of the following...

Need an html file sematable example or working sample with static json or html data with following...Pls kindly help me

  1. Read only grid as above without edit, delete and save option.
  2. The grid with many export options - pdf, csv, excel, word etc.,
  3. When the pagination is enabled - goto page option to navigate to particular page
  4. Copy to clipboard and print option
  5. Support quickest rendering for alteast 5,000 rows with page size as 10, 100, 500, 1000, 5000
  6. Search all columns or individual columns
  7. Export selected or all columns

Example grid

http://institut-de-genomique.github.io/Ultimate-DataTable/
https://w3lessons.info/2015/07/13/export-html-table-to-excel-csv-json-pdf-png-using-jquery/

Reference

  1. http://2.bp.blogspot.com/-yTiytux2848/Vcj-b5FjyUI/AAAAAAAAdQk/8rzPAsyU4Dw/s1600/jQuery%2Bdatatables%2Bexport%2Bto%2Bpdf.png
    2 . https://www.phpflow.com/wp-content/uploads/2015/09/export-table-data-toexcel-png-pdf.png
  2. https://i.stack.imgur.com/XeCzz.png
  3. https://stackoverflow.com/questions/45901407/static-data-grid-10k-records-with-search-pagination-export-options
  4. https://datatables.net/extensions/scroller/examples/initialisation/large_js_source.html

Unable to use sematable (errors at table initialization time)

I have tried using sematable but I get errors from your library when it tries to initialize the table, even though I've pretty sure I've passed in all the (at least documented) parameters.
The error is as follows:
Uncaught TypeError: Cannot read property 'forEach' of undefined
at selectors.js:179
at index.js:65
at index.js:27
at Object.selector [as getFilterOptions] (index.js:76)
at Connect.mapStateToProps [as finalMapStateToProps] (sematable.js:110)
at Connect.computeStateProps (connect.js:146)
at Connect.updateStatePropsIfNeeded (connect.js:204)
at tryCatch (connect.js:64)
at Connect.handleChange (connect.js:291)
at Connect.trySubscribe (connect.js:240)
And it is printed out in the console right after the action 'sematable/TABLE_INITIALIZE' is logged by the logger.
Aside from this problem, I would strongly suggest that you include a complete example of use of sematable in a third party app. Perhaps this may clarify some misunderstandings about the component's requirements (I believe the current documentation is helpful but not complete. E.g. it does not explain clearly what props should look like) that may help resolve this problem.
Thanks!

Better cosmetics for NN of NN element

screen shot 2017-04-26 at 5 12 52 pm

Would this look and read a little nicer if it:

  • didn't have a box/border
  • the number (10) was right aligned, so it's closer to "of"
  • had up/down arrows to the left of the first number, so that it part after that reads more easily: "10 of 83", without something visual in-between the numbers

Consider using deep equality checks for data

I'm opening this based on the proposed changes in #58. We should consider using deep equality checks to make sematable more developer-friendly, but this change should be done in the next major release.

Custom page sizes

It would be nice if we could make the values in the PageSize selector configurable. Would this be a relatively simple change? Haven't dug around the code too much yet.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.