Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Filtering ListGrid With setSelectionProperty() Set

    Hi,

    I have a listgrid that uses the setSelectionProperty method.
    The issue I am running into is when I clear a filter on the grid, the fields that are supposed to be selected are not even though they are marked as `true` with the setSelectionProperty set.

    Is this a bug or does setSelectionProperty() not support filtering?

    -Zhene

    #2
    In general, maintaining selection across filtering can be a tricky problem when data paging is involved, because when filter criteria change, the new dataset may be only partially loaded: even if you know the primaryKeys of the records that were previously selected, they may not be loaded, and so getSelectedRecords() can't return complete data.

    What is your situation here, specifically:

    1) do you have DataSource for this grid with a primaryKey defined?

    2) are you working with a paged dataset or is all data guaranteed to be loaded?

    3) assuming you're in the most difficult case (partial loading and trying to maintain selection), have you reviewed all of the code that might ask for the selection, and what specifically would it need in order to work properly (in other words, could it work with just PK values, if that's all that's available)?

    Comment


      #3
      To answer you questions:

      1) Yes, I have a DataSource for this grid with primaryKeys.
      2) I am working with a paged dataset.
      3) Yes, it would work with just PK.

      What I have are two grids. One is the parent grid and the other is a child grid. When I make a selection in the parent grid, I use the customSelectExpression in the boolean type dataSourceField to mark it if the child is associated with the parent grid using the setSelectionProperty method. This current works great except when filtering.

      Click image for larger version

Name:	Screenshot 2023-05-04 105001.png
Views:	114
Size:	115.4 KB
ID:	270118
      Last edited by zhene; 4 May 2023, 06:52. Reason: Image for better understanding

      Comment


        #4
        In general, because of the issues explained above, there is no way for the selection API to fully function in this scenario where there is paged data (we cannot, for example, fulfill even basic APIs like getSelectedRecords() if the data is simply not present).

        So, the best approach now depends on what you wanted the selection API to do for you:

        1) if you just wanted styling, you can use the same property you derived via customSelectExpression to drive some styling logic, such as a getBaseStyle() override

        .. or ..

        2) if you wanted to also track and modify some kind of permanently stored notion of selection, you could a boolean field that would appear as a checkbox and would be populated by the value you derive customSelectExpression, and make it editable (consider listGridField.canToggle to make this more immediate).

        .. or ..

        3) if you wanted something else, like doing some kind of operation on all selected records, there is no way that could work with just the client-side concept of selection tracking offered by the ListGrid (because again, the framework doesn't have the data). So, the right approach might be to make a custom server operation that operates on the server's concept of the records that are selected (since the client doesn't know them all), or alternatively, fetch just the IDs of all of the selected records from the server, then initiate client-based operations from that list

        --

        Also, just a note that your team has a special support arrangement with us, where you have requested that all support issues go through a single account. So please post any further issues from that account (it's Austin's, in case that helps). Thanks!

        Comment


          #5
          Thank you Isomorphic,

          After reading your response I believe the best approach is to simply hilite the associated records based off the customSelectExpression I have. All I need is something visual for the user to know which records are assigned to the parent grid.

          Thanks for the heads up. I'll start having Austin post my requests going forward.

          Comment

          Working...
          X