Code Monkey home page Code Monkey logo

Comments (4)

feudify avatar feudify commented on May 26, 2024 1

Of course! Sorry, I was using your example as the basis of my code, completely forgetting it was a JS object and needed the proper key values and not "columnKey" as in your example!!

Thank you so much!

from react-smart-data-table.

joaocarmo avatar joaocarmo commented on May 26, 2024

Hi @feudify ,

Can you please provide a sample of the data structure you are receiving from your http request? No need for values, just basic data = [{ key: { nestedKey: 'String' } }].

from react-smart-data-table.

feudify avatar feudify commented on May 26, 2024

Hi @joaocarmo ,

Thanks for the quick response.

Here you go:

[
{
"_id": "5d8118b18a9b5a76dc1a71ed",
"title": null,
"firstName": null,
"lastName": null,
"fullName": "sjcsd",
"postCode": "sdsdcsdc",
"email": null,
"uniqueReference": "scsdcd",
"placeholder": null
}
]

from react-smart-data-table.

joaocarmo avatar joaocarmo commented on May 26, 2024

So I took your code and modified in a way that it should work.

Notice that you were not providing the correct keys to the headers object. You need to match the key in headers with the key in the data. If the objected is nested, then use a string and dot notation like 'key.nestedKey'. Also, boolean values need no arguments and can be passed down implicitly, e.g. withHeader.

const headers = {
  _id: {
    text: 'Id',
    invisible: true,
    sortable: false,
    filterable: false
  },
  title: {
    text: 'Title',
    invisible: false,
    sortable: true,
    filterable: true
  },
  firstName: {
    text: 'First Name',
    invisible: false,
    sortable: true,
    filterable: true
  },
  lastName: {
    text: 'Last Name',
    invisible: false,
    sortable: true,
    filterable: true
  },
  fullName: {
    text: 'Full Name',
    invisible: false,
    sortable: true,
    filterable: true
  },
  postCode: {
    text: 'Post Code',
    invisible: false,
    sortable: true,
    filterable: true
  },
  email: {
    text: 'Email',
    invisible: false,
    sortable: true,
    filterable: true
  },
  uniqueReference: {
    text: 'Unique Reference',
    invisible: false,
    sortable: true,
    filterable: true
  },
  placeholder: {
    text: 'Placeholder',
    invisible: false,
    transform: () => {
      return (
        <button onClick={() => console.log("the button worked")}>
          Show Details
        </button>
      )
    }
  }
}

<SmartDataTable
  data={data}
  headers={headers}
  name='test-table'
  filterValue={filterValue}
  perPage={perPage}
  sortable
  withLinks
  withHeader
  loader={(
    <div>Loading ...</div>
  )}
/>

from react-smart-data-table.

Related Issues (20)

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.