GigaTables / reactables

GigaTables is a ReactJS plug-in to help web-developers process table-data in applications and CMS, CRM, ERP or similar systems.
MIT License
143 stars 30 forks source link

Uncaught TypeError: Cannot read property 'csv' of undefined #86

Closed pak11273 closed 6 years ago

pak11273 commented 6 years ago

I'm getting this error in the console.

I'm using: "react": "15.6.1", "webpack": "3.0.0", "gigatables-react": "2.3.4"

I created a backend endpoint for the ajax option to return the following json:

{
    "rows": [
        {
            "GT_RowId": 2, // optional
            "id": 2, // if there is no GT_RowId - try to fetch "id"
            "title": "Test 2st row",
            "desc": "<input type=\"text\" name=\"ttl\" value=\"Test 2nd row Test 2nd row Test 2nd row Test 2st row Test 2st row\" \/> ",
            "date": "20:40:37 17:06:2015",
            "info": "some info some info some info some info"
        },
        {
            "GT_RowId": 1,
            "id": 1,
            "title": "Test 1st row",
            "desc": "<input type=\"text\" name=\"ttl\" value=\"Test 1st row Test 1st row Test 1st row Test 1st row Test 1st row\" \/> ",
            "date": "20:40:38 17:06:2015",
            "info": "some info some info some info some info"
         }
    ]
}

Here is my component:

import React, {Component} from 'react'
import {Reactables, Header} from 'gigatables-react'

class Container extends Component {
  constructor() {
    super()
  }

render() {
  var settings = {
      struct: {
        // all in
        search: ['top', 'bottom'],
        rowsSelector: ['asc', 'top', 'bottom'],
        pagination: ['bottom']
      },
      ajax: 'http://192.168.68.8:3001/gigatables',
      columns: [
        {data: 'id'},
        {data: 'desc'},
        {data: 'title'},
        {data: 'date'},
        {data: 'types'},
        {data: 'info'}
      ]
    }
    return (
      <div>
        <Reactables settings={settings}>
          <Header data="id">ID</Header>
          <Header data="title">Name</Header>
          <Header data="desc">Description</Header>
          <Header data="date">Date</Header>
          <Header data="info">Info</Header>
          <Header data="field2">Field123 but data from field2</Header>
          <Header data="field1">Field1</Header>
          <Header data="field3">Field3 invisible</Header>
          <Header>Field3 invisible</Header>
       </Reactables>
      </div>
    )
  }
}
export default Container

Any ideas?

arthurkushman commented 6 years ago

Hi - thank u for exploration, there is no tests/checks for csv in settings, so for now u can just add:

        download: {
            csv: false,
        },

into settings.struct, I'll fix this soon.

arthurkushman commented 6 years ago

Here is the patch with fix for douwload.csv - https://github.com/GigaTables/reactables/releases/tag/2.3.5