PDA

View Full Version : Filter Function


cmgmyr
04-07-2008, 08:14 PM
Hey All,
I have a datagrid hooked up to an XML file through an HTTPService I would like to add a checkbox to each row so that the user can select which rows they want to view together. Then when they click a checkbox outside of the datagrid it will show only the selected rows. How do I do something like that?

Thanks,
-Chris

drkstr
04-07-2008, 08:52 PM
I would type your dataProvider as an XMLListCollection, then set the filterFunction property on it.


Best Regards,
~Aaron

cmgmyr
04-07-2008, 10:07 PM
Sorry, but I'm not quite sure what you mean...I'm still new at this stuff. Here is my datagrid
<mx:DataGrid dataProvider="{diamondList}" x="34" y="141" width="1068" height="459" id="diamondSearchList" editable="false" enabled="true">
<mx:columns>
<mx:DataGridColumn headerText="Lot Number" dataField="lot_number" />
<mx:DataGridColumn headerText="Shape" dataField="shape" />
<mx:DataGridColumn headerText="Size" dataField="carat" />
<mx:DataGridColumn headerText="Color" dataField="color" />
<mx:DataGridColumn headerText="Clarity" dataField="clarity" />
<mx:DataGridColumn headerText="Cut" dataField="cut" />
<mx:DataGridColumn headerText="Lab" dataField="lab" />
<mx:DataGridColumn headerText="Pol." dataField="polish" />
<mx:DataGridColumn headerText="Sym." dataField="symmetry" />
<mx:DataGridColumn headerText="Depth" dataField="depth" />
<mx:DataGridColumn headerText="Table" dataField="table" />
<mx:DataGridColumn headerText="Measurements" dataField="measurements" width="130" />
<mx:DataGridColumn headerText="Price" dataField="price" />
</mx:columns>
</mx:DataGrid>

Thanks,
-Chris

kahuja
04-08-2008, 07:35 AM
Some steps (I do not have the time to code it up just yet); hoping you can read through some of the help:

1. Use an Item Rendered to put in check boxes in the DataGrid;
2. Make sure that as you are clicking on the Check boxes, they register the "Selected" with an array collection
2a. Alternatively, you can also, read the check box state later, but I prefer a more real-time approach, saves time later;
3. Once a user clicks on the check box outside the grid, read the ids as stored earlier and then apply filter on the XMListCollection.
- Filter is a capability that Collections provide in ActionScript.

Refer to livedocs for more help

kahuja
04-08-2008, 07:37 AM
Look at thread: http://www.actionscript.org/forums/showthread.php3?p=728806#post728806

cmgmyr
04-08-2008, 12:18 PM
great thanks! I will try that out.

kahuja
04-08-2008, 07:25 PM
and do not forget back to let me know how it went :-)

cmgmyr
04-11-2008, 11:40 PM
Hey, sorry it took so long to get back to you about the post. I did some research and I got a little further. I got the checkbox in there ok by using <mx:DataGridColumn headerText="Compare" itemRenderer="mx.controls.CheckBox" textAlign="center" /> but then when I tried to go on from there I hit a brick wall.

I've tried to do searches for what you are saying but I couldn't find anything that is similar to what I want to do.

Where do I go from here? Can you give me or point me to an example of what I want to do? Sorry for being so "thick" but this just isn't clicking for me.

On a side note, I come from a PHP background and it is very easy to find resources and examples of TONS of things. How come it doesn't seem like that that with flex? Am I not looking in the right direction? Is it still too "new" and not enough people have a good grasp of it yet?

Thanks!
-Chris

kahuja
04-13-2008, 07:32 AM
I am underway of bogging about Collections and how can you get the Filters using. I am not there yet as this is one of many threads that I am trying to juggle with.

Meanwhile, you can go through the following example of managing 3 check-box(s) as provided by Adobe. See if that helps.

http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&postId=545&productId=2