Announcement

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

    Listgrid-dependent selectItem

    Is there a simple way of getting a selectitem to derive its values from the current displayed records of a listGrid?

    If a selectitem matches field A and the ListGrid displays the following:

    Code:
    record  fieldA  fieldB fieldC...
        1   blue    
        2   green   
        3   red
        4   orange
        5   orange
    then the selectItem should display blue, green, red, orange. (only one "orange" should be displayed).

    If something in the listgrid changes and item 2 is removed, for example - then the corresponding item (green) should be removed from the picklist.

    Thanks in advance,

    Terry

    #2
    Hi pattinsont,

    just a guess: Isn't that handled automatically once you use the same DS (with SmartGWT primary key in the .ds.xml) for both databound components?

    Best regards,
    Blama

    Comment


      #3
      Hi Blama,

      Thanks for your input. Unfortunately it isn't. I'll give an example.

      Using the Tiling Filter / Sort Showcase demo, drop the age down to 12. You'll notice that the items displayed have a status of "Not endangered" or "Threatened". However, if you use the "endangered status" selectItem, it has all endangered status's (which are present in the DS). If you then select a status that is not present in the tilebox, no records are returned.

      What I need is to limit the options displayed by the selectItem to those that are currently valid for the listGrid or tileGrid.

      Hope that makes sense.

      Thanks,

      Terry

      Comment


        #4
        The attached screenshot illustrates the issue.

        Thanks,

        Terry
        Attached Files

        Comment


          #5
          Hi pattinsont,

          in your 1st post you wrote "removed", while you are talking about criteria - big difference.
          Filtering does of course not delete.

          My guess is that in your case it could work like this:
          1. Some handler on the ListGrid or its ResultSet
          2. Some logic in the handler to build your list of value/displayValue.
          3. Call to yourItem.setValueMap()
          4. Perhaps some logic to keep the selected value, if it is still in the new map (if not done automatically, did never try).


          Best regards,
          Blama

          Comment


            #6
            Hi Blama,

            Thanks for your comments. I can draw out a Record[] from the listGrid / tileGrid, build a resultant map with the required detail and use that as a ValueMap. I felt that this was cludgy and would have a nasty performance hit; every selectItem would need to traverse every Record - which might be happening in the background anyway. What I was looking for was a way of using a ListGrid / TileGrid as a "DS" for a selectGrid (or more accurately, the dynamicForm that holds the selectItem). Whether this would be a native DS (used either as a DataSource or an OptionDataSource) or perhaps just passing the grid's Record[] to some hypothetical API call.

            This would allow for a hierarchy of Data views (full DS to grid Records to dynamicForm), and would greatly simplify the code.

            Another alternative I have tried is to use an OptionDataSource (referencing the source DS) and passing the filter criteria used to generate the ListGrid, but that results in many duplicate entries (in the previous example, it would result in "not threatened", "endangered", "not threatened","not threatened","not threatened", etc). This is expected as I'm not using the OptionDataSource correctly ;-)

            Thanks again for your ideas.

            Terry

            Comment

            Working...
            X