Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failed to populate boolean value to table column #607

Closed
parisking opened this issue Aug 5, 2016 · 12 comments
Closed

Failed to populate boolean value to table column #607

parisking opened this issue Aug 5, 2016 · 12 comments

Comments

@parisking
Copy link

parisking commented Aug 5, 2016

I have issue to populate data with boolean value. I always got warning:
Is there a recommended way to display the isSupported field below?

var products = [
   {
      id: 1,
      name: "Name1",
      isSupported: true
   },
  {
     id: 2,
     name: "Name2",
     isSupported: false
   }
 ];   

<BootstrapTable data={products} >
      <TableHeaderColumn isKey={true} dataField="id">ID</TableHeaderColumn>
      <TableHeaderColumn dataField='name'>Name</TableHeaderColumn>
      <TableHeaderColumn dataField='isSupported'>Supported</TableHeaderColumn>
</BootstrapTable>
@AllenFang
Copy link
Owner

@parisking, I'll check this out. but what warning you got?

@parisking
Copy link
Author

warning.js:44 Warning: Failed propType: Invalid prop children supplied to TableColumn, expected a ReactNode. Check the render method of TableBody.

stacktrace is:

warning @ warning.js:44
checkPropTypes @ ReactElementValidator.js:189
validatePropTypes @ ReactElementValidator.js:208
createElement @ ReactElementValidator.js:242
(anonymous function) @ TableBody.js:196
(anonymous function) @ TableBody.js:150
render @ TableBody.js:149

@luisburgos
Copy link

Hi @parisking @AllenFang I had the same problem. I think the warning is the next:

vendor.bundle.js:2241 Warning: Failed propType: Invalid prop "children" supplied to 
"TableColumn", expected a ReactNode. Check the render method of "TableBody"

I used the dateFormat property like in the examples in order to set the boolean value:

function supportedFormatter(cell, row){
  return '<i></i> ' + cell;
}

<BootstrapTable data={products} >
      <TableHeaderColumn isKey={true} dataField="id">ID</TableHeaderColumn>
      <TableHeaderColumn dataField='name'>Name</TableHeaderColumn>
      <TableHeaderColumn dataField='isSupported ' dateFormat={supportedFormatter}>Supported</TableHeaderColumn>
</BootstrapTable>

The table will display the text 'true' or 'false' depending on the boolean value. Using the function, you can change the value to be displayed to 'supported' or 'unsupported' instead. This could be an approach to solve your problem.

@parisking
Copy link
Author

Thanks. I will try again

@AllenFang
Copy link
Owner

Anyway, I'll keep to track this issue in recent, if necessary, I'll open it again. Thanks guys :)

@parisking
Copy link
Author

Still have warning and can't populate the boolean data even with suggestion of LuisBurgos

@parisking parisking reopened this Aug 5, 2016
@sgentile
Copy link

sgentile commented Aug 9, 2016

FYI I'm having the same issue and had to use a formatter like above to fix it

@AllenFang
Copy link
Owner

I'll check out this issues quickly. Sorry for lately fixing... busy on work ;(

@parisking
Copy link
Author

I finally find that it works with LuisBurgos's solution.

@AllenFang
Copy link
Owner

HI all, this issue fixed on v2.4.4. Thanks :)

@AllenFang
Copy link
Owner

AllenFang commented Aug 28, 2016

there's one thing to notice, on v2.4.4 I move the css files from css to dist folder, remember to update the css path. I apologize for it. BTW, you can also update to v2.5.0, there's nothing change, just bump the minor version

@luisburgos
Copy link

Thanks @AllenFang!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants