Of course, there are many ways to do this, but one simple approach would be
to pass a reference to the dataGrid into the pop-up.  That would give you
access to the DG.columns array to populate your columns ComboBox.

 

Tracy Spratt,

Lariat Services, development services available

  _____  

From: [email protected] [mailto:[email protected]] On
Behalf Of Angelo Anolin
Sent: Monday, May 25, 2009 10:07 AM
To: [email protected]
Subject: Re: [flexcoders] Flex DataGrid Filter via Popup Window

 






Some updates on this.

Instead of the codes inside a function, what I did was create a custom MXML
Component (selecting File | New | MXML Component) and selecting TileWindow
on the Based As dropdown list.

In the button, I created a function that calls the MXML component via the
following codes:

private function launchFilterDialog() :void
{
  var winFilter:FilterDialog = PopUpManager.createPopUp(this, FilterDialog,
true) as FilterDialog;
  PopUpManager.centerPopUp(winFilter);
}

Next step is to be able to pass the column names as defined in the datagrid
and bind those column names into the combo box which I placed in the MXML
component.

So I am left with the following things to do:

1. Get the column names of the datagrid which is in the calling flex
application.
2. Pass those column names into the MXML component and bind them into the
combo box.
3. When a selection is made on the filter dialog window and valid filter is
specified, clicking on the OK button would filter the datagrid of the
calling flex application.
4. A clear button would clear the filter(s) specified on the datagrid.

Inputs would be highly appreciated in doing Item no. 1

Thanks.

 

  _____  

From: Angelo Anolin <[email protected]>
To: [email protected]
Sent: Monday, 25 May, 2009 15:48:25
Subject: [flexcoders] Flex DataGrid Filter via Popup Window


Hello FlexCoders,

I am trying to implement a datagrid filtering mechanism to datagrids in my
application.

In this process, I want to show a popup window where it would act like a
response window.  The popup window will contain three controls, namely, two
comboboxes, and a textinput control.  One of the combo box would contain the
columns currently displayed in the datagrid.  The other combo box would
contain common comparison operators (i.e. =, !=, >, <, like, etc.). Of
course, there would also be two buttons - OK and Cancel to perform the
filter operations.

I found a popup panel example here..
http://blog. flexexamples. com/2007/ 08/06/creating- custom-pop-
<http://blog.flexexamples.com/2007/08/06/creating-custom-pop-up-windows-with
-the-popupmanager-class/>  up-windows- with-the- popupmanager- class/

But in this example, he is defining the content of the popup panel.

Since we know that the controls in the popup panel is fixed, would it be
possible to just create another control which contains the controls we have
defined?  Then, the combobox panel would be populated with the columns in
the datagrid where it was called. When the column selection from the combo
box is made, the operator also selected and the text input is filled up with
the value to filter, clicking on OK button would filter the datagrid.

Another reason that I wanted that the filter mechanism reusable because I
have a lot of mxml with datagrid that requires the same filter
functionality. It would not be too good if I would place all the codes in
each mxml, right?

I am not sure if this approach would be good.  If in case you have other
approach on how to filter the datagrid, kindly let me know.

Thanks.

 



Reply via email to