Data Grid Column Header Problem

zryip theSlug zryip.theslug at gmail.com
Sun Sep 5 19:40:48 EDT 2010


On Mon, Sep 6, 2010 at 12:34 AM, Len Morgan <len-morgan at crcom.net> wrote:
>
>> Len,
>>
>> The ideal min size is 40.
>> I gave your problem a try. It seems to me that the content of your
>> columns is centered. In this case, changing the margins with the
>> "header margins" do nothing, because the field displaying the header
>> title has a width of 2 pixels.
>>
>> If you can give 10 more pixels for those two columns, all will be ok.
>> Otherwise, for now I don't see any workaround.
>>
>>
>> Regards,
>
> "Ideal" according to who?  Is that a Rev limitation or part of the Data
> Grid?  It seems to be awfully large.  I did expand those columns (and
> reduced the width of another to make them fit) so it's all "working" now.
>  It sure would be nice if we could lower that limit though.
>

"Ideal" according to my quick test, sorry. So I correct myself: 40
seems to be the ideal width.

Here is a workaround if you have no need to sort your two columns. You
have to define a default header behavior and change the layoutControl
handler. The header width of a datagrid seems to take care of the
width of the "sort arrow" you can have in the header in case you want
to sort a column.

on LayoutControl pControlRect
    -- Position all of the controls within the header
    put the loc of me into theLoc
    set the margins of field 1 of me to the dgProps["header margins"]
of the dgControl of me
    set the rect of graphic "Background" of me to pControlRect
    set the rect of field 1 of me to pControlRect
    set the left of graphic "LeftHilite" of me to item 1 of pControlRect
    set the right of graphic "RightHilite" of me to item 3 of pControlRect

    -- Position field and sort arrow --> Your width problem should be here
    put the width of button "SortArrow" of me into theArrowWidth
    set the loc of button "SortArrow" of me to item 3 of pControlRect
- (round(theArrowWidth / 2) + 5), item 2 of the loc of me
    add 5 to theArrowWidth
    if the textAlign of field 1 of me is "center" then
        set the rect of field 1 of me to item 1 of pControlRect, item
2 of pControlRect, \
                item 1 of pControlRect + ( (item 3 of pControlRect -
item 1 of pControlRect) - (theArrowWidth * 2) ), \
                item 4 of pControlRect
        set the loc of field 1 of me to theLoc
    else
        if the visible of button "SortArrow" of me then
            set the rect of field 1 of me to item 1 of pControlRect,
item 2 of pControlRect, \
                    item 1 of pControlRect + ( (item 3 of pControlRect
- item 1 of pControlRect) - theArrowWidth ), \
                    item 4 of pControlRect
        else
            set the rect of field 1 of me to item 1 of pControlRect,
item 2 of pControlRect, \
                    item 1 of pControlRect + ( (item 3 of pControlRect
- item 1 of pControlRect) ), \
                    item 4 of pControlRect
        end if
    end if
end LayoutControl

The lesson to change the header behavior is here:
http://lessons.runrev.com/spaces/lessons/manuals/datagrid_tips/lessons/7351-How-Do-I-Add-Tooltips-To-Column-Headers-


HTH


Regards,
-- 
-Zryip TheSlug- wish you the best! 8)
http://www.aslugontheroad.co.cc



More information about the use-livecode mailing list