React Grid - Custom header together GridColumnProps.sortable

1 Answer 992 Views
Grid
Vladislav
Top achievements
Rank 2
Iron
Iron
Vladislav asked on 05 Jan 2022, 02:42 PM

Hi.

My question is. Is it possible to enable  property  'sortable' together with the custom property 'headerCell' on the grid column? Because it doesn't work for me. Template for column header is ok, but sorting does not work - icons are not visible (k-icon k-i-sort-asc-sm / k-icon k-i-sort-desc-sm) and does not sort. But sorting through the column menu works.

Well thank you.

1 Answer, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 06 Jan 2022, 05:45 AM

Hello,

Yes, this is possible. We provide the icon and its events inside props.children in the headerCell:

https://www.telerik.com/kendo-react-ui-develop/components/grid/styling/#toc-adding-custom-header-cells

const ProductNameHeader = (props) => {
  return (
    <a className="k-link" onClick={props.onClick}>
      <span className="k-icon k-i-cart" />
      <span
        style={{
          color: "#53d2fa",
        }}
      >
        {props.title}
      </span>
      {props.children} // when sorting is enabled the sorting icon and its click handler will be here
    </a>
  );
};

Regards,
Stefan
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Vladislav
Top achievements
Rank 2
Iron
Iron
commented on 07 Jan 2022, 01:21 PM

Excellent. It works. Well thank you.
Tags
Grid
Asked by
Vladislav
Top achievements
Rank 2
Iron
Iron
Answers by
Stefan
Telerik team
Share this question
or