Table column header not highlighted at first

  • I have a table view with a column + column header with a sort
    descriptor. In use, it works fine, I can click the column header and
    it sorts the list as it should, and the little arrow points up or down
    and it's blue.

    When I first show the window though, it's white and no arrow is
    visible. Clicking it turns it blue. What do I need to do to make it
    come up properly first time? The table is the initialFirstResponder
    and that works correctly.

    Slightly weird - I have another list in the same window and its column
    headers come up fine. I can't see what I'm doing differently in the
    two cases, though that list has 3 columns and the one that doesn't
    work only has 1. For both lists I use the list's sortDescriptors to
    initially sort the items prior to loading the table when the window is
    first displayed.

    tia,

    Graham
  • On Aug 14, 2008, at 9:28 PM, Graham Cox wrote:

    > I have a table view with a column + column header with a sort
    > descriptor. In use, it works fine, I can click the column header and
    > it sorts the list as it should, and the little arrow points up or
    > down and it's blue.
    >
    > When I first show the window though, it's white and no arrow is
    > visible. Clicking it turns it blue. What do I need to do to make it
    > come up properly first time? The table is the initialFirstResponder
    > and that works correctly.

    Howdy! call setSortDescriptors: on the tableview -- pass it the
    [tableColumn sortDescriptorPrototype] in an array.

    >
    >
    > Slightly weird - I have another list in the same window and its
    > column headers come up fine. I can't see what I'm doing differently
    > in the two cases, though that list has 3 columns and the one that
    > doesn't work only has 1. For both lists I use the list's
    > sortDescriptors to initially sort the items prior to loading the
    > table when the window is first displayed.

    Ah, never mind my first answer. Exactly how are you doing this (code)?
    When? Are you sure you aren't setting it to nil by accident? Are you
    using these at all, and if so, how:

    /*
      * Persistence methods
      */
    - (void)setAutosaveName:(NSString *)name;
    - (NSString *)autosaveName;

    /* On Mac OS 10.4 and higher, the NSTableColumn width and location is
    saved. On Mac OS 10.5 and higher, the NSTableColumn 'isHidden' state
    is also saved. The 'autosaveName' must be set for
    'autosaveTableColumns' to take effect.
    */
    - (void)setAutosaveTableColumns:(BOOL)save;
    - (BOOL)autosaveTableColumns;

    corbin
  • On 16 Aug 2008, at 1:27 am, Corbin Dunn wrote:

    > Howdy! call setSortDescriptors: on the tableview -- pass it the
    > [tableColumn sortDescriptorPrototype] in an array.
    >
    >>
    >> []

    > Ah, never mind my first answer. Exactly how are you doing this
    > (code)? When? Are you sure you aren't setting it to nil by accident?
    > Are you using these

    Well, that worked fine, so if you don't mind I will take your first
    answer!

    I need to figure out why the second table works even though I'm not
    doing anything special (and none of the autosave stuff you mentioned
    either).

    cheers, Graham
  • On Aug 15, 2008, at 8:36 AM, Graham Cox wrote:

    >
    > On 16 Aug 2008, at 1:27 am, Corbin Dunn wrote:
    >
    >> Howdy! call setSortDescriptors: on the tableview -- pass it the
    >> [tableColumn sortDescriptorPrototype] in an array.
    >>
    >>>
    >>> []
    >
    >> Ah, never mind my first answer. Exactly how are you doing this
    >> (code)? When? Are you sure you aren't setting it to nil by
    >> accident? Are you using these
    >
    >
    > Well, that worked fine, so if you don't mind I will take your first
    > answer!
    >
    > I need to figure out why the second table works even though I'm not
    > doing anything special (and none of the autosave stuff you mentioned
    > either).

    It's possible that it could be set in the nib -- make sure it isn't an
    empty space or anything. The sort descriptors are encoded with the
    tableview; maybe you have it set to sort on that column in the nib on
    the second table, but not the first. In fact, now that I think about
    it, that might be another good way to set the initial sorting.

    corbin
  • On 16 Aug 2008, at 1:36 am, Graham Cox wrote:

    > I need to figure out why the second table works even though I'm not
    > doing anything special (and none of the autosave stuff you mentioned
    > either).

    OK, very simple: it was set in the nib. I didn't realise that
    presetting this in the nib was possible, so I must have set it up that
    way more or less by accident. OK, my understanding has improved...
    (Thanks!)

    Now I have a new problem which is somewhat related (same tables and to
    do with these sort descriptors).

    Table has two columns, one of which contains strings, the other,
    checkboxes. I set up a sort descriptor for the strings column and that
    works great. Then I came to add a sort descriptor to the checkbox
    column. This requires a custom compare method so I wrote one, then set
    that up as the sort descriptor's selector, with 'self' as the keyed
    property.

    Something weird happens in IB. As soon as I add this information to
    the column, my two column headers seem to get locked together - they
    both turn blue at the same time, and clicking either one inverts both
    of them together. I can't seem to fix this - even scrapping the table
    and starting over I end up in the same fix. This is in IB long before
    my own code gets a shot at it - and when it does it's the same story -
    the columns lock together.

    What on earth is going on, and how to fix it?

    tia,

    Graham
  • On 16/08/2008, at 11:26 PM, Graham Cox wrote:
    >
    > OK, very simple: it was set in the nib. I didn't realise that
    > presetting this in the nib was possible, so I must have set it up
    > that way more or less by accident. OK, my understanding has
    > improved... (Thanks!)
    >

    Hi, I have been following this thread and was wondering how you
    actually set the sort descriptor in the nib. I've looked at the
    bindings tab and tried different things but haven't yet got it to work.

    Regards,
    Jason
  • On 17 Aug 2008, at 11:06 pm, Jason Wiggins wrote:

    >
    > On 16/08/2008, at 11:26 PM, Graham Cox wrote:
    >>
    >> OK, very simple: it was set in the nib. I didn't realise that
    >> presetting this in the nib was possible, so I must have set it up
    >> that way more or less by accident. OK, my understanding has
    >> improved... (Thanks!)
    >>
    >
    > Hi, I have been following this thread and was wondering how you
    > actually set the sort descriptor in the nib. I've looked at the
    > bindings tab and tried different things but haven't yet got it to
    > work.

    I'm not using bindings - not sure in what way that would be different.

    Set a sort descriptor for a column by entering a key and selector in
    the relevant fields of the inspector (if you just enter a key, it
    enters 'compare:' as the selector for you, but you can change it).

    To set the initial sort descriptor click on the column header until it
    highlights - simple as that. However to get to that point you may have
    to click through several levels of the selection hierarchy - in my
    case my table is within a custom view within a split view so getting
    the column to highlight takes about six clicks, which is why it eluded
    me for a while there.

    hth,

    Graham
  • On Aug 16, 2008, at 6:26 AM, Graham Cox wrote:

    >
    > On 16 Aug 2008, at 1:36 am, Graham Cox wrote:
    >
    >> I need to figure out why the second table works even though I'm not
    >> doing anything special (and none of the autosave stuff you
    >> mentioned either).
    >
    >
    > OK, very simple: it was set in the nib. I didn't realise that
    > presetting this in the nib was possible, so I must have set it up
    > that way more or less by accident. OK, my understanding has
    > improved... (Thanks!)
    >
    >
    > Now I have a new problem which is somewhat related (same tables and
    > to do with these sort descriptors).
    >
    > Table has two columns, one of which contains strings, the other,
    > checkboxes. I set up a sort descriptor for the strings column and
    > that works great. Then I came to add a sort descriptor to the
    > checkbox column. This requires a custom compare method so I wrote
    > one, then set that up as the sort descriptor's selector, with 'self'
    > as the keyed property.
    >
    > Something weird happens in IB. As soon as I add this information to
    > the column, my two column headers seem to get locked together - they
    > both turn blue at the same time, and clicking either one inverts
    > both of them together. I can't seem to fix this - even scrapping the
    > table and starting over I end up in the same fix. This is in IB long
    > before my own code gets a shot at it - and when it does it's the
    > same story - the columns lock together.

    Do you have any console logs? It sounds like an exception is being
    raised by IB. Other than that, I don't know...I haven't heard of this
    before.

    corbin
previous month august 2008 next month
MTWTFSS
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Go to today