1) I have a DataGrid, well, it's actually an AdvancedDataGrid, but for
your purposes, it doesn't matter.
2) I have some comboBoxes,that apply filters to the DataGrid using
filterFunction. The example below just shows one comboBox, but I have
several, and a slider also.
3) Ok, here's the problem: I want to give my users the ability to
select multiple rows in the datagrid using
selectionMode="multipleRows" - then press a button to only show the
rows that are highlighted. I need this functionality to incorporate
the other filters that I built - so it has to be in the filterFunction
code.
4) I also want to be able to 'reset' the grid so that the formerly
highlighted rows re-appear, but the other filters stay intact. Another
button perhaps.
The code is too cumbersome to show here, so if you can show an example
using the following snippets, that'll be great:
Simplified Grid:
Advertise
|
About us
|
Site map
|
Syndicate
|
Search site
|
Mailing list
|
View Authors
|
Become an Author
Home Tutorials Forums Articles Blogs Movies Library
Employment
Press Buy templates
Go Back ActionScript.org Forums > Flex > Flex 2 & 3
Reload this Page DataGrid + filterFunction + selectedItems
User Name Remember Me?
Password
Register FAQ Members List Calendar Today's Posts Search
Search Forums
Show Threads Show Posts
Advanced Search
Go to Page...
Reply
Thread Tools Rate Thread Display Modes
Old Today, 07:20 PM #1
matchoo
Registered User
Join Date: Dec 2008
Posts: 2
Red face DataGrid + filterFunction + selectedItems
Greetings,
Ok, it's been two days of misery for me, a wife that complains I am
obsessed with work, and a boss that keeps asking "where is it?"
So, this problem has a bounty. I like Pizza. Do you like Pizza? The
first male, female, hermaphrodite, or genderless martian to solve my
problem gets one large pizza with whatever toppings they want. Respond
with your solution, and if it works, you can tell me your favorite
local pizza place, and I'll have it delivered to you with a nice green
salad, and some cans of soda to boot.
No, I'm serious.
Here's the information you need to proceed:
1) I have a DataGrid, well, it's actually an AdvancedDataGrid, but for
your purposes, it doesn't matter.
2) I have some comboBoxes,that apply filters to the DataGrid using
filterFunction. The example below just shows one comboBox, but I have
several, and a slider also.
3) Ok, here's the problem: I want to give my users the ability to
select multiple rows in the datagrid using
selectionMode="multipleRows" - then press a button to only show the
rows that are highlighted. I need this functionality to incorporate
the other filters that I built - so it has to be in the filterFunction
code.
4) I also want to be able to 'reset' the grid so that the formerly
highlighted rows re-appear, but the other filters stay intact. Another
button perhaps.
The code is too cumbersome to show here, so if you can show an example
using the following snippets, that'll be great:
Simplified Grid:
Code:
<mx:HTTPService id="videoServiceSource" result="handleData(event)"
resultFormat="e4x" url="{urlString}" showBusyCursor="true" />
<mx:XMLListCollection id="videoData"
source="{videoServiceSource.lastResult.*}" />
<mx:HTTPService id="videoPublisherSource" result="handleDataPub
(event)" resultFormat="e4x" url="{urlString}">
<mx:request>
<a>publisher</a>
</mx:request>
</mx:HTTPService>
<mx:XMLListCollection id="videoPublisher"
source="{videoPublisherSource.lastResult.*}" />
<mx:Script>
<![CDATA[
import mx.events.CollectionEvent;
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
import mx.utils.ObjectUtil;
import mx.controls.Alert;
import mx.events.ListEvent;
import mx.utils.ArrayUtil;
import mx.controls.advancedDataGridClasses.*;
import mx.events.AdvancedDataGridEvent;
[Bindable] public var urlString:String = "index.php";
[Bindable] public var publisherData:XMLListCollection;
private function init():void
{
//I do stuff here to chain http service calls - no need
to see my
custom class for that
var chain:ServiceChain = new ServiceChain();
chain.add(videoPublisherSource, handleDataPubl);
chain.chainFinishedHandler = chainFinished;
chain.run();
}
private function chainFinished():void{
videoServiceSource.send();
}
}
private function handleData(event:ResultEvent):void
{
videoData = new XMLListCollection();
videoData.source = event.result.video;
videoData.filterFunction = filterVids; //SETS FILTER FOR
DATAGRID
videoData.refresh();
}
private function handleDataPub(event:ResultEvent):void
{
studioData = new XMLListCollection();
studioData.source = event.result.studio;
}
private function handlePubChange():void
{
//videoData.filterFunction = filterVids; //no need to
redeclare
videoData.refresh();
}
private function filterByChecks():void{
//THIS SHOULD JUST REFRESH THE FILTERS... CODE SHOULD
GO IN
filterVids section
videoData.refresh();
}
private function unfilterByChecks():void{
//THIS SHOULD JUST REFRESH THE FILTERS... CODE SHOULD
GO IN
filterVids section - BUT WITH ALL ROWS SHOWING AS THEY WERE BEFORE
SELECTED ROWS WERE FILTERED
videoData.refresh();
}
private function filterVids(item:Object):Boolean {
if(
(item.publisher == publisher.value || publisher.value ==
'All')
&&
(
//HERE IS WHERE I WANT TO LOOK AT SELECTED ROWS AND
FILTER
//UNLESS NO ROWS ARE SELECTED - APPLY
NO FILTER
//HOW TO ACCESS THAT?
)
)
{
return true;
} else {
return false;
}
}
]]>
</mx:Script>
<mx:Label text="Publisher" width="49" textAlign="right"/>
<mx:ComboBox id="publisher" dataProvider="{videoPublisher}"
change="handlePubChange()" width="149"/>
<mx:Button label="show selected rows only" click="filterByChecks()"/>
<mx:Button label="show all rows again" click="unfilterByChecks()"/>
<mx:AdvancedDataGrid id="grid" dataProvider="{videoData}"
selectionMode="multipleRows">
<mx:groupedColumns>
<mx:AdvancedDataGridColumn headerText="Video
ID"
dataField="video_id" width="0"
visible="false" />
<mx:AdvancedDataGridColumn headerText="Title"
textAlign="left"
dataField="title" width="110"
headerStyleName="centerAligned" />
<mx:AdvancedDataGridColumn
headerText="Publisher"
dataField="publisher" width="90"
headerStyleName="centerAligned"/>
</mx:groupedColumns>
</mx:AdvancedDataGrid>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---