Tuesday, June 19, 2007
Summary customization in AdvancedDataGrid
ADG allows customization of Summary and Grouping with various callback functions and properties. One such property available on the SummaryField class is the label property which allows one to customize the property name used for the summary data. This example shows one such usage to skip displaying any estimate information at the leaf level but display a budget summary data at the Territory level.
The mxml file is here.
Subscribe to:
Post Comments (Atom)
34 comments:
sreenivas, how can values be assigned at the country (eg. USA) or region (eg. Southwest) level except count functions (COUNT, SUM, etc)?
For example, if I want to lookup USA value in another arraycollection and display it at the that level.
> USA {President value}
arrayCollectionB {[Country:"USA", President:"Bush".......
You can use the Grouping.groupingObjectFunction or GroupingField.groupingObjectFunction to return any object with additional information. The returned object will get tagged with the group label and used as the data item for the row.
Let me know if that doesn't serve your purpose.
Would you be able to post an example? Thanks!
a sample
Sreenivas, thanks for the example. Very helpful. I have been working on filtering for Advanced datagrid. I saw some of Sameer's work and it's nice, but if you could show a more advanced example, it would be great. (eg. filtering on a multi hierarchy table.)
Assuming you mean HierarchicalData when you mention hierarchical table isn't it straight forward?
If you set adg.dataProvider.filterFunction to any custom function after it has been turned into HierarchicalCollectionView the filtering should work for all child nodes.
So I think no sample is required here. If you want a specific example let me know !
Hi Sreenivas,
Most of the people use array to populate their AdvancedDataGrid, but me I am using an XML file. MY XML file has 3 sub level. I see the structure of the file properly in my datadrid.
But my problem is when I Call the filtering function. It is supposed to be called on each element of the grid. But it only triggers on the top level elements of the XML.
I think I may have to group the data together in order to make it hierarchical ... even if it's already the case.
Would you have an example of how filtering/grouping XML data ?
Is your data getting displayed as you want in the datagrid ?
If your answer is yes then I would say you do not require any grouping.
The data passed on to the filtering would be the top level node. But you can always drill down using e4x syntax or XML itself and filter it based on sublevel elements.
In case you want sub nodes to be also treated as data rows you can use HierarchicalData to pass data into AdvancedDataGrid. You can apply filtering then.
adg.dataProvider = new HierarchicalData(new XMLCollection(myXMLData));
adg.validateNow();
//do filtering here
Grouping using XML data sample is here http://flexpearls.blogspot.com/2008/05/grouping-xml-data-using.html
Thank you for your comment.
In fact, I add to filter my XML data manualy before the insertion in the dataprovider.
My data are well displayed. SO the hierarchy is good.
I was having problem because I wanted open or close the nodes after a refresh.
I actualy store the id of my object, and at each refresh, because my data are updated, I loop on my xml document and set the expand values to true for each object I want.
SO now everything is working fine.
Thank you again for your blog
HI can we directly use XMLListCollection for grouping instead of ArrayCollection.
Iam working on Grouping in ADG it contains around 2000 records.
Iam using a web service which returns me data in xml format which iam taking into an XMLListCollection and then taking records from this collection and filling another ArrayCollection which would be used for Grouping.
But this whole process take lots of time. I was wondering cant i directly use XMLListCollection for grouping??
XMLListCollection can be directly set as source to GroupingCollection.
Hi Sreenivas
Thanks a lot.....
I am now able to use XMListCollection as a source for GroupCollection.
But one problem is like iam not able to calculate Summary?
At the Summary Row it is showing 0
earlier when I was using ArrayCollection as a source It was giving me accurate total.
here is my code where GroupingCollection source is an XMLListCollection.
var sumRow:SummaryRow= new SummaryRow();
var sumField1:SummaryField= new SummaryField('SPEND_PRE','SUM');
var sumField2:SummaryField= new SummaryField('SPEND_CUR','SUM');
gf = new GroupingField();
grp = new Grouping();
gc= new GroupingCollection2();
gc.source = searchResultXMLColl;
sumRow.summaryPlacement='group';
sumRow.fields=[sumField1,sumField2];
gf.numeric=true;
gf.name='DBDUNS_NUM';
gf.summaries=[sumRow];
grp.fields=[gf];
gc.grouping=grp;
gc.refresh();
adg1.dataProvider=gc;
Thanks
Surender Dahiya
Can you send me a sample project which doesn't work?
Hey I have sent u the code at ur gmail Id Kinldy look into it.
Moreover after using XMLListCollection on Grouping I dont see my LinkButton that i have used as ItemRenderer on my first Column.
LinkButton Appears when I group Using ArrayCollection or when I display FlatData using XMLListCollection but not when i group using XMLListCollection
Hey sreenivas,
Any updates sir? I have been stuck up on that.
Please help its very urgent.
Hi Sreenivas,
Can u grouping be done on data where the Primary key is composite Key?
i.e
The following is the structure of my data.
where "DBDUNS_NUM","DB_CNTRY_NAME" and DB_CNTRY constitute my primary Key.
DBDUNS_NUM-000000000
DUNS_NAME-PG
CREDITOR-0015011777
CREDITOR_NAME-FPG OLEOCHEMICALS
SDN BHD
COUNTRY-MY
CNTRY_NAME-MALAYSIA
DB_CNTRY-LOC
DB_CNTRY_NAME-USA
SPEND_PRE-0.00
SPEND_CUR-6444.45
STATE-CHECKED
DBDUNS_NUM-000000000
DUNS_NAME-PG
CREDITOR-0015024692
CREDITOR_NAME-LPG ENGINEERING
(THAILAND) CO LTD
COUNTRY-TH
CNTRY_NAME-THAILAND
DB_CNTRY-USA
DB_CNTRY_NAME-USA
SPEND_PRE-0.00
SPEND_CUR-62595.00
STATE-CHECKED
DBDUNS_NUM-000000000
DUNS_NAME-PG
CREDITOR-0015039633
CREDITOR_NAME-PG
COUNTRY-VN
CNTRY_NAME-VIETNAM
DB_CNTRY-LON
DB_CNTRY_NAME-UK
SPEND_PRE-0.00
SPEND_CUR-33928952.84
STATE-CHECKED
DBDUNS_NUM-00000000
DUNS_NAME-PG
CREDITOR-0015039839
CREDITOR_NAME-PG
COUNTRY-VN
CNTRY_NAME-VIETNAM
DB_CNTRY-TEN
DB_CNTRY_NAME-UK
SPEND_PRE-571286.55
SPEND_CUR-3863445.05
STATE-CHECKED
The structure should be like.
Vendor_No Country
>000000000 USA
->0015011777 Malaysia
->0015024692 Thailand
>000000000 UK
->0015039633 Vietnam
->0015039834 Vietnam
Please Help I have no idea how to go about this problem.
Thanks in advance.
You can use groupingFunction and compareFunction on GroupingField to achive this result.
A sample file is here.
Hi Sreenivas,
Thanks for the example.
Hi Sreenivas,
Iam using the solution provided by you for composite key and also my data provider is an XMLListCollection.Iam using grouping where iam setting gc.children='xxx'.
I get the following error.
"ReferenceError: Error #1056: Cannot create property xxx on String."
and when i comment "gc.children='xxx'" I get the same error.
"ReferenceError: Error #1056: Cannot create property children on String."
what could be the reason?
am I missing something??
Thanks in advance.
I think you are returning a String where a Object was expected.
Are you providing any custom function for groupObjectFunction or groupFunction and returning a String where the expected value is an object ?
Hi Sreenivas,
Thanks for the Hint.I solved it.
One more thing i would like to ask , Iam using grouping in Advanced DataGrid.I have around 300groups and each group contains 10 records on average.
When i use adg1.expandAll() method on this my flash player crashes giving me time out error.Can something be done to avoid it? like in in grouping we uses Async refresh.
You can try opening only the visible parent nodes. Also log a bug in JIRA so that in case it can be fixed it can be tracked.
Hi Sreenivas,
I'm novice in Flex and your posts help me a lot. Thank you.
I need filter the summary row with a textinput value (only show if the sum is greater then 100, for example). Can you help me please? (sorry about my english, I'm Brasilian)
Kalili
You can try filtering the rows by specifying a filter function to ADG.dataProvider.filterFunction and then calling refresh.
In the filter function you should return false for the rows in which the summary is outside the range you wish to display.
Hi, Sreenivas,
Thank you for your answer. Could you send me an example to filterfunction getting summary values and filter it?
Thank you again
Hello Sreenivas,
I am a flex newbie. And I have a weird problem (may be to me).Actually I need to group the second column (uses an XML) and the last column, which is a summary field.The first column of the ADG is a custom checkbox item renderer.(I have used Sameer's three state checkbox idea) to create this.If I am trying to group the first and last column , the data is not getting loaded into the ADG. Can u help me in this regard.Its priority one for me.Thanks in Advance.
Srividhya, without taking a look at some sample code showing the problem I cannot suggest anything. If you can create a sample project and send it to me I would be able to take a look.
Hello Sreenivas,
Thank you very much for your response.Could you please post your email id so that I can send a mail containing my sample code.
Thank you in advance.
sreenivas dot ramaswamy at gmail dot com
Hello Sreenivas,
Have you got any ideas regarding my code? I am really stuck.
I have get some nodes hierarchy lost using a XMLList as source of GroupingCollection please advise
whoa!!!, you had a passion in blogging, thumbs up for your work of love.. Hehe very inspiring ideas,
anyway I'm william
mind if I put a link back to you?
(clickable) ------> Suit
is there anything by which i can change the ICON of tree after a event.
Post a Comment