5 Replies Latest reply on Mar 14, 2007 9:46 AM by midimidi

    Getting myGrid.selectedItems to properly *select*...

      I have an application with a popup window that is created from a function on click. The popup has a datagrid. The "get all data" function for the grid is coming from a simple component that brings in the data, called inside the popup - lets say an AC allData. The comopnent inside the popup broadcasts an event saying "done loading" and I'm handling that event in the popup to select myData.selectedItems, based on the data passed from a custom event in the man application..

      The grid properly displays all data from the data component. The selectedItems arrayCollection is definitely available to the popup. It is an AC of myValueObject, seen in the debugger. The manager's "get all data" is also an AC of myValueObject.

      In the above scenario, it doesn't work when I say myGrid.selectedItems = selectedData as Array.

      Instead, I have another function "getSelection(selectedData)" which basically loops through the selectedData AC and
      pushes each item to a new Array and returns that array. I've triple checked this, and it also does not work. As a test, to make sure its not realted to the "loading" process of the popup, I've even set the "getSelection" function to run via a button's click so that it is well after everything is loaded in the popup. It still selects nothing.

      BUT! If I have "myGrid.selectedData = getSelection(allData)" where allData is the same exact AC that is used to populate the grid's dataProvider, it selects all items in the grid. What's totally odd, is the AC from the dataProvider and the AC for selectedData look absolutely *identical* in the debugger, minus a bunch of items for the selectedData, as it should be.

      The only working alternative I can figure out is to create another function in the data component that "re-gets" the selectedData. While this works, it is unfortunately not acceptible, because other areas of the application might change the selectedData, without calling to the database. I need to keep moving that data around to components all over the application freely without calling him.

      Any thoughts on what's wrong here?

      Here's a screen capture to emphasize the complication:

      qnotemedia.com / wontwork.gif

      ...note that in the above example, only arSecondSelection actually works. The others select nothing.