Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Arjan H. 221 posts 457 karma points c-trib
    Jan 17, 2023 @ 18:28
    Arjan H.
    0

    Is it possible to set a read-only Name property for a collection?

    I have a bunch of read-only collections, but when I use the SetNameProperty() to configure the Name column for the list view the Name is editable on the editor view (header). The changes can't be saved because I've disabled Create/Delete/Update for these collections. But editors still get an 'unsaved changes' warning when the accidentally change the Name value.

    As a workaround I've removed the SetNameProperty() method and used the SetNameFormat() method instead, but the downside of using this method is that the list view can no longer be sorted by Name.

    Is there a way to use SetNameProperty() but have the Name field read-only or disabled on the editor view?

  • Arjan H. 221 posts 457 karma points c-trib
    Jan 17, 2023 @ 18:49
    Arjan H.
    0

    When sorting on the Name column the orderBy parameter is null in GetPagedImpl() when only using the SetNameFormat() method to configure the Name property for the collection. Since I'm using a custom KonstruktRepository for my collections I was able to fix the issue by setting the orderBy to a specific property when it's null.

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jan 18, 2023 @ 09:16
    Matt Brailsford
    100

    Hey Arjan,

    Yea, I'd say the best way to do this is to use SetNameFormat() like you are doing, however I've just run a test locally and when using SetNameFormat I am still able to sort on the name field in the list view 🤷‍♂️

  • Arjan H. 221 posts 457 karma points c-trib
    Jan 18, 2023 @ 10:31
    Arjan H.
    0

    Then it's probably due to my custom KonstruktRepository implementation. Like I said, I was able to fix it by setting the orderBy to a specific property when it's null:

    enter image description here

    In the OOTB implementation, is the orderBy parameter not null when sorting on the Name column with only SetNameFormat() being used and SetNameProperty() is left out completely?

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jan 18, 2023 @ 10:45
    Matt Brailsford
    0

    Seems to be populated for me 🤷‍♂️

  • Matt Brailsford 4124 posts 22215 karma points MVP 9x c-trib
    Jan 18, 2023 @ 10:50
    Matt Brailsford
    1

    Ahh, maybe it works for me because the field I'm falling back to is still called Name but it looks like you want InvoiceNumber, so if you had a Name property it would probably work.

  • Arjan H. 221 posts 457 karma points c-trib
    Jan 18, 2023 @ 10:53
    Arjan H.
    0

    Yeah, I just came to the same conclusion. I added a Name field to the custom collection class and used that for the SetNameFormat(), and now sorting works.

Please Sign in or register to post replies

Write your reply to:

Draft