Search code examples
nattable

Nattable sort on button click, placed on column header


GIVEN: I have a nattable with sort enabled.

TODO: 1) Instead of UP/DOWN black triangles which appear on column header i want buttons with same images to appear 2) I also want sort to happen when i click on these buttons

WHAT I HAVE TRIED: I tried using a SortIconPainter but, i can set only custom images in this. I have no idea how to get buttons on column header.

Any suggestion is appreciated.


Solution

  • You can not have buttons in table cells. It is a custom rendered table and not a widget container. You can pass images that look like buttons and register an IMouseAction with an IMouseEventMatcher that checks for the painter and the image. Not a trivial task.

    You can have a look at the ButtonCellPainter and whether it is possible to combine it with another painter in a CellPainterDecorator. Actually I am not a big fan of that painter as it uses a lot of asynchronous code for the pseudo animation. But maybe it suits your needs.