3 Replies Latest reply on Oct 31, 2006 7:17 AM by dkerr

    datagrid select to query in other datagrid

      I have a datagrid of agent names and a datagrid of tickets. I'd like the user to select an agent in one grid and filter the tickets down to just the selected agent's tickets in the ticketsgrid.

      I'm using remoteobject talking to a Cold Fusion CFC. I'm new to AS and I'm trying to learn how to pass the selected agent name to the query and return the new results to the ticketgrid.

      In general, What do I add to the MXML in the agentgrid?

      In general, What Actionscript do I need?

      I think I see how to modify the CFC side, but not the Flex Builder 2 MXML/AS side.

      If this is not the best way to do this, I'm open to suggestions.



        • 1. Re: datagrid select to query in other datagrid
          peterent Level 2
          Whenever you click a row in a DataGrid several events are fired. One is the itemClick event:

          <mx:DataGrid itemClick="handleAgentClick(event)" ... >

          The event parameter tells you the row and column of the click which lets you know which "agent" the user picked. Now that you have that information you can use that to change the Collection of the ticket's grid to display just that argent's tickets.

          Check out these topics in the Flex 2 docs:
          * itemClick event (DataGrid)
          * filterFunction (Collections)

          Your filterFunction can look at a variable in the <mx:Script> block that you set from within the function that handles the itemClick on the agent DataGrid. Once that variable is set, call the ticket dataProvider's refresh function and the ticket grid will then show only those tickets that the filterFunction allows.
          • 2. Re: datagrid select to query in other datagrid
            dkerr Level 1
            Thank you Peter. I'll research these suggestions and look for example code since I'm new to AS. Sounds like a pretty slick solution without having to go back to the CFC with the agentid and re-run the ticket query.

            I appreciate the response very much.
            • 3. Re: datagrid select to query in other datagrid
              dkerr Level 1
              Well...the flex docs lang ref isn't too helpful for someone new to AS...at least for those that learn by example.

              Anyone have some basic example code of filterFunction in action. I'm using RemoteObject to populate the Grid with tickets in initapp(). Then wanting to filter by agent name.

              There is an example code that I'd like to get working with my Grid
              Category: USING DATA
              Entries: DATA FILTERING

              I tried modify this code to talk to a datagrid that is populated by a remoteobject query, instead of the static
              <mx:ArrayCollection id="myData">
              that is used in this example.

              Had trouble uderstanding what to change all the "mydata" references to so that it points to my ticketgrid results instead of the static arraycollection.

              Or do I somehow make my CFGRID remote object build an <mx:ArrayCollection id="myCFCdata"> or something like that??

              Again, this is a learning exercise to understand how AS works in relation to a ColdFusion CFC remoteobject. I need to understand the "flow" and "positioning" of the code.

              Once I learn this piece, then I'll try the filter with a LIST container picking the agent from a list instead of typing their name in this example.