Search code examples
sortingbuttonhtml-tableant-design-pro

Can i handle antDesign Table go up and down with up & down aroow button


enter image description here

i want change row's order(up and down) when i click arrow button(it doesn't exist now, i will make)

 const onRow = (record, rowIndex) => {
    return {
      onClick: (event) => {
        setSelectedIndex(rowIndex);

        const aniSeq = record.aniSeq;
        const aniOwnerNo = record.aniOwnerNo;
        const aniRFID = record.aniRFID;
        const aniNationalID = record.aniNationalID;
        const aniGroupCd = record.aniGroupCd;
        setAniSeqSel(aniSeq);
        setAniSeq(aniSeq);
        setAniOwnerNo(aniOwnerNo);
        setAniRFID(aniRFID);
        setAniNationalID(aniNationalID);
        setAniGroupCd(aniGroupCd);

        let cowObj = { aniSeq, aniOwnerNo, aniRFID, aniNationalID, aniGroupCd };
        props.onCreate(cowObj);
      },
    };
  };
 {
      title: '착유시간(s/회)',
      width: '15px',

      align: 'center',
      dataIndex: 'milkingtmmPerStr',

      sortDirections: ['descend', 'ascend', 'descend'],
      sorter: (a, b) =>
        String(a.milkingtmmPerStr).localeCompare(b.milkingtmmPerStr),
      //...getColumnSearchProps("milkingtmmPerStr"),

      render(text, record) {
        return {
          props: {
            style: { background: text < '00:05:00' ? 'white' : 'white' },
            // style: { background: text < '00:05:00' ? 'red' : 'white' },
          },
          children: <div>{text}</div>,
        };
      },
    },

it's my onRow code and column code example, how can i handle them? when i click arrow button, i wannna go up it's row or go down. but i don't know about it and how to use ant-design table well


Solution

  • Do it in WPF, the Property named CanUserSort=true.

    If you would like to do in the Code you can use

    var list = myList.OrderBy(x => x.MyValue).ToList();