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

Checkbox multiselect automatically with datatable #97

Closed
vivekp9690 opened this issue Jan 16, 2020 · 6 comments
Closed

Checkbox multiselect automatically with datatable #97

vivekp9690 opened this issue Jan 16, 2020 · 6 comments

Comments

@vivekp9690
Copy link

Using checkbox in 'MDBDataTable' with pagination there is one issue with it... When I click on checkbox of a particular position of data table (For example 1st row of the data table) of 1st page, than checkbox of all other pages automatically selected at same position.

Means if I check any checkbox of any row of any page, its automatically checked same position(row) of all other pages.

@jakubchmura
Copy link
Contributor

Hi @vivekp9690,

Please paste here your code sample here. Without this, I'm not able to help.

Or move the topic to the MDB support forum https://mdbootstrap.com/support/cat/react/, Our forum is visited by many more people than the issues tab on GitHub, so I think you will get a faster response there.

Remember to attach an example of your code!

Best, Kuba

@vivekp9690
Copy link
Author

Hello @JakubChm ,
Can you check here
Link: https://afkar-staging.sharedt.com/#/client/datatable-demo
When you click on any pagination on 4 or 5 and click on checkbox and you see the issue it's select the checkbox on same position for all page.
Thank you

@vivekp9690
Copy link
Author

`

var pushArr = [];
for(var i=0; i < rows1.length; i++){  

  pushArr.push({  chk:<div className="checkbox form-check">
    <div className="custom-checkbox custom-control custom-control-inline">
      <input type="checkbox" className="custom-control-input"  onChange={this.handleChange} value={rows1[i].id} id={rows1[i].id}  />
      <label class="custom-control-label" for={rows1[i].id}></label>
     </div> </div>,

           
      id:rows1[i].id,
      title: rows1[i].title
   })

}
const rows = [];

  const data = {
columns: [
  {
    label: 'chk',
    field: 'chk',
    sort: 'asc',
    width: 150
  },
  {
    label: 'id',
    field: 'id',
    sort: 'asc',
    width: 150
  },
  {
    label: 'title',
    field: 'title',
    sort: 'asc',
    width: 270
  }
],
rows:  pushArr   };

return (
  <>
   
     <MDBDataTable
        responsive
        hover
        data={data}    
        sortRows={[]}
      />
  
  </>
);   }

`

@jakubchmura
Copy link
Contributor

I know this topic from the MDB support forum. This is not a bug in our product, it is a user issue caused by poor state management.

@vivekp9690
Copy link
Author

vivekp9690 commented Feb 5, 2020

@JakubChm
so can you give me a solution for this what i make error in above code ? and you say this is not your problem so put one example with checkbox and pagination in table?

@yathkapoor07
Copy link

@JakubChm I'm facing the same issue and have even incorporated individual state values for each Checkbox field.
Is there an update on this issue?

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

No branches or pull requests

3 participants