DataGrid header issue with center alignment

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller

Post Reply
Nikos
Posts: 14
Joined: Sun Oct 26, 2014 12:49 pm

DataGrid header issue with center alignment

Post by Nikos » Sun Nov 02, 2014 9:09 am

My DataGrid header alignment efforts are encountering some strange behaviour. Here's what I'm doing:

- Drag a datagrid onto the card ("dg1")
- Put "TheText" into the Contents (a single row, a single column)
- Put "TheColumnHeader" into the first column label (column name is "Col 1"). This is purposefully longer than the column text to demonstrate the below.

By default, both column and header are left aligned. If you resize the column width via the drag-handle, notice than when you drag it to the left you can reach the edge of the Header text ("TheColumnHeader") exactly (to the pixel), and if you continue dragging left you start to cover (hide) part of this text.

This seems normal. Now:

- set the dgHeaderAlignment["Col 1"] to "center".

This caused 2 bad things to happen:

1. If you now try again to resize the column width via the drag-handle, a buffer/margin part has appeared to the right of the header text. Meaning that, when resizing the column by moving the drag-handle to the left, the header text starts to become hidden many pixels before the column vertical line reaches the right edge of the text "TheColumnHeader". This "margin" area is about 2-3 characters wide on each side, and needless to say, has nothing to do with dgProp["header margins"], I am not touching this at all. This means that I am forced to create columns much wider than required, otherwise the Header text becomes hidden/truncated on the left and right. Remember, this happens only on "center" alignment of the header, on "left" or "right" I can trim column width to the pixel. Center alignment on the column text itself also works OK.

2. The column resizing drag-handle itself has become erratic. Moving the mouse over the column divider, the drag-handle does not always appear. It appears the first time, but if you move the mouse slightly to the left or right, moving it back over the column divider does not make the handle re-appear. It seems to work better if you move the mouse outside the whole DG before attempting it again.

I tested on LC6.7 and LC7.0 and both have the same behaviour.

Is the above normal? Is there something different about "center" alignment" of headers in the DataGrid?

I would have also liked to try a custom header row template to see if that would work better, but I don't see how to do that for headers (it only seems to be available for normal rows).

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”