mui-datatables icon indicating copy to clipboard operation
mui-datatables copied to clipboard

How to change sort icon position to left side of the label

Open vijaysai88zemoso opened this issue 7 years ago • 3 comments

can you provide one more prop for changing the sort icon position to left/right of column head label

vijaysai88zemoso avatar Sep 25 '18 13:09 vijaysai88zemoso

@vijaysai88zemoso Did you found solution?

whaberek avatar Apr 06 '20 15:04 whaberek

For now, this can be done using the customHeadRender column option. This is not the easiest solution but it will be of help. Example:

const columns = [
    {
      name: "date",
      label: "Date",
      options: {
        filter: false,
        sort: true,
        customBodyRender: (value, tableMeta, updateValue) => {
          return (
            <span>
              {moment(value?.toDate() ?? new Date()).format("Do MMM YYYY") ??
                ""}
            </span>
          );
        },
        customHeadRender: (columnMeta, handleToggleColumn, sortOrder) => {
          return (
            <div
              className="text-uppercase"
              onClick={() => handleToggleColumn(columnMeta?.index)}
            >
              <IconButton
                icon={
                  sortOrder == "asc" ? (
                    <Icon icon="arrow-up" />
                  ) : (
                    <Icon icon="arrow-down" />
                  )
                }
              />
              {String(columnMeta?.label)}&ensp;
            </div>
          );
        },
      },
    },
]

You can shift icon to left or right.

BossBele avatar Feb 11 '21 11:02 BossBele

A bit complicated but it works @BossBele

develanton avatar Jul 22 '22 19:07 develanton