Easy :) I just did this myself... I allow my users to select the columns to
display in one particuliar inbox, so it updates automatically.
1) If you notice the columns property on the datagrid is just an array of
DataGridColumns objects. So what I do I created a component to hold these
arrays with any label functions and such:
<mx:UIComponent>
<mx:Array id="mycolumns">
<mx:DataGridColumn ..../>
....
</mx:Array>
</mx:UIComponent>
2) Then you can create a class to do the filtering for you, meaning takes the
columns the user selected and constructs a new array with only the ones
selected or you can extend the DataGrid to have a new property called
"selectedColumns" and pass in the array of columns the user selected and do the
work in there. I did the former for now, but will probably refactor in the days
to come... hopefully :)
Dimitrios Gianninas
RIA Developer
Optimal Payments Inc.
________________________________
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of rob_scio
Sent: Monday, December 18, 2006 12:26 PM
To: [email protected]
Subject: [flexcoders] Print Datagrid Columns Dynamically Based on User Selection
We are looking for suggestions on how to handle the following:
We need to print a DataGrid with DataGrid columns chosen by a user at
runtime in a dynamic fashion. The app that's been written utilizes the
mx.printing.FlexPrintJob method to accomplish this task.
Specifically, the code already written for the PrintDataGridExample
example provided in the ASDoc has been leveraged (great example by the
way) and integrated it into an app as a starting point.
The example falls short of where our app needs to be taken in this way...
we have a requirement that the user be able to print the data
displayed in the datagrid with the dynamically selected columns (and
not just a standard set of columns). We want to specify the DataGrid
columns at runtime making the app more dynamic for our clients. The
application is a search app that allows the users to choose the
individual fields that they not only wish to search on but also select
which fields to display in the final report product.
We've considered simply passing to the DataGrid's dataProvider the
'raw data' thus allowing the DataGrid to dynamically set the columns
but we must also provide special formatting for the certain fields at
runtime like a currency field (if chosen) and the date fields (if chosen).
We know how to provide the raw data to the dataProvider at runtime AND
we know how to format pre-defined <mx:columns> with specific
itemRenders at design-time to apply special formats to the appropriate
cells. We just haven't yet combined the two methods. Any
help/suggestions would be greatly appreciated. Thanks in advance.
Rob
--
WARNING
-------
This electronic message and its attachments may contain confidential,
proprietary or legally privileged information, which is solely for the use of
the intended recipient. No privilege or other rights are waived by any
unintended transmission or unauthorized retransmission of this message. If you
are not the intended recipient of this message, or if you have received it in
error, you should immediately stop reading this message and delete it and all
attachments from your system. The reading, distribution, copying or other use
of this message or its attachments by unintended recipients is unauthorized and
may be unlawful. If you have received this e-mail in error, please notify the
sender.
AVIS IMPORTANT
--------------
Ce message électronique et ses pièces jointes peuvent contenir des
renseignements confidentiels, exclusifs ou légalement privilégiés destinés au
seul usage du destinataire visé. L'expéditeur original ne renonce à aucun
privilège ou à aucun autre droit si le présent message a été transmis
involontairement ou s'il est retransmis sans son autorisation. Si vous n'êtes
pas le destinataire visé du présent message ou si vous l'avez reçu par erreur,
veuillez cesser immédiatement de le lire et le supprimer, ainsi que toutes ses
pièces jointes, de votre système. La lecture, la distribution, la copie ou
tout autre usage du présent message ou de ses pièces jointes par des personnes
autres que le destinataire visé ne sont pas autorisés et pourraient être
illégaux. Si vous avez reçu ce courrier électronique par erreur, veuillez en
aviser l'expéditeur.