imballinst / react-bs-datatable

Bootstrap datatable without jQuery. Features include: filter, sort, pagination, checkbox, and control customization.
https://imballinst.github.io/react-bs-datatable
MIT License
59 stars 20 forks source link

How do i start? #62

Closed Itedjere closed 2 years ago

Itedjere commented 4 years ago

I am confused on how to start using it. I have installed it. But how to start

Do i have to use the storybook pattern like you did in the examples.

Please guide me or show me resources to read on how to start.

Thanks

imballinst commented 4 years ago

hello! sorry for the late reply. I also just realized that there is no "Usage" section in the README. I'll try to add that. You don't have to use Storybook, for example, to use it in your React app, you can use this:

import React from 'react';
import moment from 'moment';
import Datatable from 'react-bs-datatable';

const header = [
  { title: 'Username', prop: 'username' },
  { title: 'Name', prop: 'realname' },
  { title: 'Location', prop: 'location' },
  { title: 'Last Updated', prop: 'date' }
];

const body = Array.from(new Array(57), () => {
  const rd = (Math.random() * 10).toFixed(1);

  if (rd > 0.5) {
    return {
      username: 'i-am-billy',
      realname: `Billy ${rd}`,
      location: 'Mars',
      date: moment()
        .subtract(1, 'days')
        .format('Do MMMM YYYY')
    };
  }

  return {
    username: 'john-nhoj',
    realname: `John ${rd}`,
    location: 'Saturn',
    date: moment()
      .subtract(2, 'days')
      .format('Do MMMM YYYY')
  };
});

// Now, you can use `<Table />` component elsewhere.
const Table = () => (
  <Datatable
    tableHeaders={header}
    tableBody={body}
  />
));
Itedjere commented 4 years ago

Wow thank you so much

This really helps me as a beginning 😂

Thanks.

Itedjere Godspower

On Thu, May 21, 2020, 06:09 Try Ajitiono notifications@github.com wrote:

hello! sorry for the late reply. I also just realized that there is no "Usage" section in the README. I'll try to add that. You don't have to use Storybook, for example, to use it in your React app, you can use this:

import React from 'react'; import moment from 'moment'; import Datatable from 'react-bs-datatable';

const header = [ { title: 'Username', prop: 'username' }, { title: 'Name', prop: 'realname' }, { title: 'Location', prop: 'location' }, { title: 'Last Updated', prop: 'date' } ];

const body = Array.from(new Array(57), () => { const rd = (Math.random() * 10).toFixed(1);

if (rd > 0.5) { return { username: 'i-am-billy', realname: Billy ${rd}, location: 'Mars', date: moment() .subtract(1, 'days') .format('Do MMMM YYYY') }; }

return { username: 'john-nhoj', realname: John ${rd}, location: 'Saturn', date: moment() .subtract(2, 'days') .format('Do MMMM YYYY') }; });

const Table = () => ( <Datatable tableHeaders={header} tableBody={body} /> ));

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Imballinst/react-bs-datatable/issues/62#issuecomment-631883932, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF25MBNN5YNCGPLA2HFYBIDRSSZQVANCNFSM4NA3I63Q .

imballinst commented 4 years ago

all good @Itedjere! Please let me know if you have further questions 👍