Topic: Data Table Order Not Working

Joshua Moore free asked 2 years ago


Expected behavior The datatable should sort by order and it is not

Actual behavior There is no sorting happening with the table

Resources (screenshots, code snippets etc.) I have the following code and the order is not filtering this data by school asc const data = {

  columns: [
    {
        label: "School",
        field: "school",
        sort: "asc",
        width: 150,
    },
    {
        label: "Name",
        field: "name",
        sort: "asc",
        width: 150,
      },
      {
        label: "Avatar",
        field: "avatar",
        sort: "asc",
        width: 150,
      },
      {
        label: "Title",
        field: "title",
        sort: "asc",
        width: 150,
      },
      {
        label: "Email",
        field: "email",
        sort: "asc",
        width: 150,
      },
      {
        label: "Usertype",
        field: "usertype",
        sort: "asc",
        width: 150,
      }
  ],
  rows : users.map(user => {
    return {
        school: user.school_name,
        name: user.name,
        avatar: (
          <img src={user.avatar} className="img-fluid rounded" style={{height: "60px"}} />
        ),
        title: user.title,
        email: user.email,
        usertype: user.userType
    }
})
}
return(
    <Fragment>
        <ToastContainer />
        <MDBDataTable order={['school', 'asc' ]} entriesOptions={[50, 75, 100]} entries={50} striped bordered small data={data} exportToCSV />;
    </Fragment>

Krzysztof Wilk staff commented 2 years ago

Hi!

I see in the specification you are using MDB React package with version 4.27.0 while the current one is 5.1.0. Bugs with sorting were fixed in 5.0.0, so I recommend updating the package and check if everything works as expected :)

Keep coding!



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Opened

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB React
  • MDB Version: MDB4 4.27.0
  • Device: Desktop
  • Browser: All
  • OS: Mac
  • Provided sample code: No
  • Provided link: No