After the element-ui table is paged, the date is sorted out, only the current page is sorted, not the whole data.

for example, the table is sorted according to the date order before paging, and the date is sorted disorderly after paging, as shown in the following figure
this is the first page


.

obviously, the date order is out of order, but it is sorted on the current page, not the whole sort.
my code is as follows

<template>
  <div>
    ...
          <div>
            <el-table
              :data="tableData.slice((currentPage-1)*pagesize,currentPage*pagesize)"
              border
              style="width: 100%"
              :default-sort = "{prop: "date", order: "descending"}">
              <el-table-column
                prop="date"
                label="Modified Date"
                width="180">
              </el-table-column>
              <el-table-column
                prop="name"
                label="Experiment Name"
                width="180">
              </el-table-column>
              <el-table-column
                prop="content"
                label="Content"
                width="640">
              </el-table-column>
            </el-table>
            <br><br>
            <div class="block">
              <el-pagination
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :current-page="currentPage"
                :page-sizes="[10, 20, 30, 40]"
                :page-size="pagesize"
                layout="total, sizes, prev, pager, next, jumper"
                :total="tableData.length">
              </el-pagination>
            </div>
            </div>
...
</template>

<script>
...
    export default{
      data() {
        return {
          tableData:[{
            date: "",
            name: "",
            content: ""
          }],
          currentPage: 1,
          pagesize:10
        }
      },
      mounted: function(){
        this.getAbHistory();
      },
      methods:{
        handleSizeChange(size) {
          this.pagesize = size;
        },
        handleCurrentChange(currentPage) {
          this.currentPage = currentPage;
        },
        getAbHistory(){
          axios.get("/historyScan/AbHistory").then(result =>{
            var res = result.data;
            if(res.status == "0"){
              let values = res.result.hbaseRst;
              var data = []
              for (let i = 0; i < values.length; iPP){
                var obj = {}
                obj.name= values[i].key;
                obj.date = moment(values[i].timestamp).format("YYYY-MM-DD HH:mm:ss");
                obj.content = values[i].$;
                data[i] = obj
              }
              this.tableData = data;;
            }
            else{
              this.$message.error("A/B test ");
            }
          });
        }

      }

    }
</script>

Please give me some advice on how to sort the whole data and how to modify the front-end code. Thank you


the sorting of the overall data should be left to the backend, and the front end can pass parameters.
if you want to do this at the front end, you need to send all the data, otherwise you can only sort the existing data (not recommended).
exactly what to do has already been answered by a friend, so I won't repeat it.


the whole data is sorted by time? That is to send a logo to the back end, and then return the data. The sorting version of element is based on


page sorting


element table sorting has a remote sort
whether the corresponding column can be sorted. If it is set to 'custom', it means that the user wants to sort remotely. You need to listen for the sort-change event
of Table, and then sort all the data at the back end, and the returned value page will sort again

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4ba5b-44e46.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4ba5b-44e46.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?