Disabling sorting in NSTableView

  • I have an NSTableView in a pretty straightforward configuration with an
    NSArrayController, with the table columns bound to various properties
    of the arrangedObjects key of the controller.  My table columns are set
    up so that they have no identifier and no sort key, but when I click on
    one of the column headers in my app, it still sorts the table by the
    key being used to retrieve the values for the table.  I also unchecked
    the "Editable" checkbox for each column, and I even programatically set
    the sortDescriptorPrototype for each column to nil, but it still sorts
    the columns when I click on the headers.  How can I completely disable
    sorting for this table view while using NSController?

    --
    Brian Webster
    <bwebster...>
    http://homepage.mac.com/bwebster
    _______________________________________________
    cocoa-dev mailing list | <cocoa-dev...>
    Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    Do not post admin requests to the list. They will be ignored.
  • Brian,

    The first part is a how to that should get you going - followed by a
    bit of explanation.

    You need to do the following:

    The How:
    Select the table view itself and inspect its bindings.

    You will see three Table Content bindings for the table view:

    content
    selectionIndexes
    sortDescriptors

    Bind the content to:

    Bind To: Your Array Controller
    Controller Key: arrangedObjects
    Model Key Path: <leave this blank>

    Bind the selectionIndexes to:

    Bind To: Your Array Controller
    Controller Key: selectionIndexes
    Model Key Path: <leave this blank>

    Leave sortDescriptors unbound

    A little of what's going on:

    Typically you only need to bind each table column value binding to the
    arranged objects of an array controller.  When you do this, behind the
    scenes, all three table view content bindings are automatically 'hooked
    up' for you.

    It is only when you need to change these three default content bindings
    that you need to visit the table view's bindings.

    You can also use this mechanism to do other things with a table view's
    bindings (like pull the selection indexes from one array controller,
    while displaying the arranged objects of another array controller).  I
    don't have a particularly good use for that in mind at the moment.

    Hope this helps.

    -James

    ---------------------------
    James Dempsey
    Operations Engineer
    Apple Software Customer Seeding
    Apple Software Engineering

    <dempsey...>
    On Nov 11, 2003, at 1:55 PM, Brian Webster wrote:

    > I have an NSTableView in a pretty straightforward configuration with
    > an NSArrayController, with the table columns bound to various
    > properties of the arrangedObjects key of the controller.  My table
    > columns are set up so that they have no identifier and no sort key,
    > but when I click on one of the column headers in my app, it still
    > sorts the table by the key being used to retrieve the values for the
    > table.  I also unchecked the "Editable" checkbox for each column, and
    > I even programatically set the sortDescriptorPrototype for each column
    > to nil, but it still sorts the columns when I click on the headers.
    > How can I completely disable sorting for this table view while using
    > NSController?
    >
    > --
    > Brian Webster
    > <bwebster...>
    > http://homepage.mac.com/bwebster
    > _______________________________________________
    > cocoa-dev mailing list | <cocoa-dev...>
    > Help/Unsubscribe/Archives:
    > http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    > Do not post admin requests to the list. They will be ignored.
    _______________________________________________
    cocoa-dev mailing list | <cocoa-dev...>
    Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    Do not post admin requests to the list. They will be ignored.
  • Ahhh, got it.  Probably would have never figured that out on my own,
    but now that I see it, it makes sense.  Thanks!

    On Nov 11, 2003, at 8:51 PM, James Dempsey wrote:

    > Brian,
    >
    > The first part is a how to that should get you going - followed by a
    > bit of explanation.
    >
    > You need to do the following:
    >
    > The How:
    > Select the table view itself and inspect its bindings.
    >
    > You will see three Table Content bindings for the table view:
    >
    > content
    > selectionIndexes
    > sortDescriptors
    >
    > Bind the content to:
    >
    > Bind To: Your Array Controller
    > Controller Key: arrangedObjects
    > Model Key Path: <leave this blank>
    >
    > Bind the selectionIndexes to:
    >
    > Bind To: Your Array Controller
    > Controller Key: selectionIndexes
    > Model Key Path: <leave this blank>
    >
    > Leave sortDescriptors unbound
    >
    >
    > A little of what's going on:
    >
    > Typically you only need to bind each table column value binding to the
    > arranged objects of an array controller.  When you do this, behind the
    > scenes, all three table view content bindings are automatically
    > 'hooked up' for you.
    >
    > It is only when you need to change these three default content
    > bindings that you need to visit the table view's bindings.
    >
    > You can also use this mechanism to do other things with a table view's
    > bindings (like pull the selection indexes from one array controller,
    > while displaying the arranged objects of another array controller).  I
    > don't have a particularly good use for that in mind at the moment.
    >
    > Hope this helps.
    >
    > -James
    >
    > ---------------------------
    > James Dempsey
    > Operations Engineer
    > Apple Software Customer Seeding
    > Apple Software Engineering
    >
    > <dempsey...>
    > On Nov 11, 2003, at 1:55 PM, Brian Webster wrote:
    >
    >> I have an NSTableView in a pretty straightforward configuration with
    >> an NSArrayController, with the table columns bound to various
    >> properties of the arrangedObjects key of the controller.  My table
    >> columns are set up so that they have no identifier and no sort key,
    >> but when I click on one of the column headers in my app, it still
    >> sorts the table by the key being used to retrieve the values for the
    >> table.  I also unchecked the "Editable" checkbox for each column, and
    >> I even programatically set the sortDescriptorPrototype for each
    >> column to nil, but it still sorts the columns when I click on the
    >> headers.  How can I completely disable sorting for this table view
    >> while using NSController?
    >>
    >> --
    >> Brian Webster
    >> <bwebster...>
    >> http://homepage.mac.com/bwebster
    >> _______________________________________________
    >> cocoa-dev mailing list | <cocoa-dev...>
    >> Help/Unsubscribe/Archives:
    >> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    >> Do not post admin requests to the list. They will be ignored.
    >>
    >>
    --
    Brian Webster
    <bwebster...>
    http://homepage.mac.com/bwebster
    _______________________________________________
    cocoa-dev mailing list | <cocoa-dev...>
    Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    Do not post admin requests to the list. They will be ignored.
previous month november 2003 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
Go to today