react-bootstrap-table2 icon indicating copy to clipboard operation
react-bootstrap-table2 copied to clipboard

Uncaught TypeError: onSort is not a function

Open rikardocorp opened this issue 8 years ago • 15 comments

react-bootstrap-table-next= ^1.4.0

Example: columns: [ { dataField: 'user.first_name', text: 'FirstName', sort: true } ]

Error: Uncaught TypeError: onSort is not a function

rikardocorp avatar Nov 07 '18 16:11 rikardocorp

Please give me an example on codesandbox.io for reproducing, thanks

AllenFang avatar Nov 10 '18 05:11 AllenFang

react-bootstrap-table-next= ^1.4.0

Example: columns: [ { dataField: 'user.first_name', text: 'FirstName', sort: true } ]

Error: Uncaught TypeError: onSort is not a function

@rikardocorp is this resolved. I'm also facing same issue

Geetakokate avatar Feb 11 '19 08:02 Geetakokate

@rikardocorp I am also facing the same issue. columns = [{ dataField: 'name', text: 'Name', sort: true }, { dataField: 'role', text: 'Role', sort: true }] When I click to sort column

Uncaught TypeError: props.onSort is not a function

pooja-mane avatar Feb 11 '19 08:02 pooja-mane

@AllenFang I may been able to reproduce the error. It seems when I store the columns in state is when I get problems with not being able to sort.

https://codesandbox.io/s/issue-652-vphgd

fulin426 avatar Sep 26 '19 17:09 fulin426

Curious why this got closed. It is a state thing. I am using hooks and had to set the headers at the beginning. I updated the headers (formatting with data coming in a load) and the sorting worked.

dmuczynski-nexient avatar Dec 17 '19 22:12 dmuczynski-nexient

Having same issue - mine is being created only when part of columns comes from props - my current workaround (which is leading to tight coupling) is by hardcoding columns into the Table function

amitsetty avatar Jan 25 '20 01:01 amitsetty

@amitsetty not even hardcoding the columns work for me :(

ghost avatar Feb 11 '20 12:02 ghost

Same problem here on version 3.3.4

rudza avatar Feb 11 '20 14:02 rudza

I have same problem because i put my data in state when it comes from api, and give it to table from state, like this.state.data, when i change to this.props.data it works grate

asaduryan avatar Feb 12 '20 09:02 asaduryan

I have same problem because i put my data in state when it comes from api, and give it to table from state, like this.state.data, when i change to this.props.data it works grate

My data is also coming from props which passed from parent component, but it still doesnt work. Can you share your code?

Grafomap avatar Feb 12 '20 09:02 Grafomap

@Grafomap there are same in my cod i pass props but in parent component take it from state. Can you give your code and we can try to solve it together

asaduryan avatar Feb 12 '20 16:02 asaduryan

@fulin426 code example working only needed to change version ov module to latest

asaduryan avatar Feb 12 '20 16:02 asaduryan

for mine to work, i updated the headers which caused my page to re-render. the sorting worked after that. i use hooks, so i just did setHeaders after my data loaded.

dmuczynski-nexient avatar Feb 14 '20 10:02 dmuczynski-nexient

@dmuczynski-nexient can you share a snippet of that code with setHeaders? I don't know what you are talking about there xD

ghost avatar Feb 14 '20 11:02 ghost

the hook: const [headers, setHeaders] = useState([]) in the useEffect (where i download the data), after i set the data, i just do this: setHeaders(updatedHeaders) updated headers includes the sort function and is dependent on the data being loaded first.

dmuczynski-nexient avatar Feb 14 '20 16:02 dmuczynski-nexient