Sorting columns in a flex datagrid
The datagrid gets its data from a back end database which has records like
RecordID Division Department Date_Report_Submitted
1. Finance Accounting 11/1/2010
2. Engineering Design 4/2/2011
3. Engineering Implementation 4/2/2011
4. Support Chat_Support 2/4/2010
Clicking on the headers in the Datagrid column(Department) results in a sort based on recordID like
Division Department Date_Report_Submitted
Finance Accounting 11/1/2010
Engineering Design 4/2/2011
Engineering Implementation 4/2/2011
Support Chat_Support 2/4/2010
whereas I want it to be sorted alphabetically for the Datagrid column(Department) like
Division Department Date_Report_Submitted
Finance Accounting 11/1/2010
Support Chat_Support 2/4/2010
Engineering Design 4/2/2011
Engineering Implementation 4/2/2011
since Accounting should come before Chat_Support as per lexicographical order.
Looked at http://blog.flexexamples.com/2008/04/09/creating-a-custom-sort-on-a-datagrid-control-in-fl ex/#more-590 and have something like
<mx:DataGrid id="myRecords" dataProvider="{myRecords_dp}" width="810" height="274"
itemClick="getRecordData(event)">
<mx:columns>
<mx:DataGridColumn id="firstCol" width="180" fontFamily="Arial" fontSize="12"
wordWrap="true" />
<mx:Button label="Click to Sort" click="mysort()" />
</mx:columns>
</mx:DataGrid>
and
private function mysort():void
var sortField:SortField = new SortField();
sortField.compareFunction = mycompare;
sortField.descending = false;
var sort:Sort = new Sort();
sort.fields = [sortField];
myRecords.sort = sort;
myRecords.refresh();
private function mycompare(lhs:Object, rhs:Object):int
var valueA:String = lhs.text();
var valueB:String = rhs.text();
return ObjectUtil.stringCompare(valueA, valueB);
I get errors like
1061: Call to a possibly undefined method refresh through a reference with static type mx.controls:DataGrid.
for myRecords.refresh();
and
Access of possibly undefined property sort through a reference with static type mx.controls:DataGrid.
for myRecords.sort
Any suggestions would be appreciated.
I should have clarified this from the start itself. The backend database has few tables. One is Divisions which has some fields like
Division ID Division Name. Another is Department which has fields like RecID, Division ID, Department Name. What is being retrieved from the dataprovider(myRecords_dp) is Rec ID, then a labelfunction converts the Rec ID into Department name by looping over the department table and displays it. So, if Implementation has a recID of 3 and Chat_Support of 4, Implementation will come before Chat_support when I click on the header so it will not be in lexicographical order.
Similar Messages
-
Is there a way of merging cells (not columns) in a Flex Datagrid?
Hello everyone!
I'm new to Flex and I have been searching for a solution to this problem for two days now, so any help would be really appreciated!
I have a datagrid of, lets say x columns of fixed size, with the ability to add or remove rows dynamically. When adding a row o popup comes up and lets the user determine the positions(order) and widths of the desired cells of the row. So what I want to do is to be able to merge cells of the new Datagrid row appropriately, to satisfy the user's choices. Thats the general idea.
Is there a way to have a Datagrid (or other similar component) with different cell number and widths for each row in Flex? I need a component similar to the Datagrid because I want to be able to select rows and process their data.
Any idea would be very helpful as I'm pressed for time and I could use someone's experience to search in the right direction and not loose time.
Thanks in advance!Thank you very much for your response. I finally did what I wanted without using a Datagrid. I used a Table Flex Component (which extends Flex Grid) that I found here:
http://code.google.com/p/flex-table/#Demo
I downloaded the source and changed some things to make it work as I need. -
Sort Column Date - DataGrid - Flex 4.5.1
Hi
I made download the function (below) to sort column date in DateGrid, but is not working
private function date_sortCompareFunc(itemA:
Object, itemB:Object):int
var dateA:Date=new Date(Date.parse(itemA.dob));
var dateB:Date=new Date(Date.parse(itemB.dob));
return ObjectUtil.dateCompare(dateA, dateB);
<s:GridColumn dataField="DATA_VENCIMENTO_ID"
width="115"
headerText="Data Vencimento"
dataTipFunction="date_sortCompareFunc">
someone can help me?
MarcosHi Marcos,
This forum here is for questions related to the LiveCycle Collaboration Service product.
You might want to post your question to the Flex forum:
http://forums.adobe.com/community/flex/flex_general_discussion
Hope this helps.
Good luck,
Julien
LCCS Quality Engineering -
Hi,
I am using flex datagrid to develop an application in french,
as french is having special character in it,
i need to sort datagrid column in french. Flex datagrid
unable to sort data in french. i need french sorting,
if somebody has solution of this please help me to get out of
this.
If possible please reply me on
[email protected]i am using inbuilt flex sorting, i am not using sortcompare()
function.
its just a string sorting but as its in french ,character
"
É" is comig after character "
V" , because flex treated it as a special character
. it should come before "
V". so do we need to change character set for
flex? -
How to disaply multiple column of a table in a single flex datagrid column
Hi,
I have a table in my database which has say 3 column (Firstname,LastName,Location). I wanted to display these 3 different values in a single column in flex datagrid.
Could you please help me out in this
Thanks,
PratikGenerally, in such scenarios each column is made corresponding to the column in database only and not single column.
However, we can setStyle of a datagrid to make it appear as if all three columns have been populated in single.
set verticalGridLines="false" for dataGrid. Further cosmetic changes can be made to realise the required look.
In some cases, labelFunction of a datagridColumn also suffices the need.
Tanu -
How to add Column to Adobe flex mx:DataGrid in mxml and/or actionsctpt?
I have simple mxml code
<mx:DataGrid id="DGG"
editable="true">
<mx:dataProvider>
<mx:Object scheduledDate="4/1/2006"/>
</mx:dataProvider>
</mx:DataGrid>
<mx:Button id="SetBut"
label="Set Array as Data Provider"
click="SetDP(); AddBut.visible = true;"
x="100.5"
y="164"
width="211"/>
<mx:Button id="AddBut"
label="Add a column!"
click="AddCol();"
x="100.5"
y="194"
width="211"
visible="false"/>
<mx:Script>
<![CDATA[
import mx.controls.dataGridClasses.DataGridColumn;
import mx.collections.ArrayCollection;
[Bindable]
public var MyAC:ArrayCollection=new ArrayCollection([{scheduledDate: "4/1/2006", homeTeam: "Chester Bucks"}]);
public function SetDP():void
DGG.dataProvider=MyAC
public function AddCol():void
MyAC.addItem({scheduledDate: "4/5/2007", homeTeam: "Long Valley Hitters", Umpire: "Amanda Hugenkis"});
DGG.columns.push(new DataGridColumn("Umpire"));
]]>
</mx:Script>
I want to add rows to my table datagrid how to do such thing?
How to add Column to Adobe flex mx:DataGrid in mxml and/or actionsctpt?
(You can put this code in Flash or AIR app - it will compile with no errors, but will not add any columns=( )Change this:
public function SetDP():void
DGG.dataProvider=MyAC
MyAC.addItem({scheduledDate: "4/5/2007", homeTeam: "Long Valley Hitters", Umpire: "Amanda Hugenkis"});
public function AddCol():void
var dgc:DataGridColumn = new DataGridColumn("Umpire");
var ca:Array = DGG.columns;
ca.push(dgc);
DGG.columns = ca;
Dany -
Flex datagrid data column / webservice
I use a web service to populate a datagrid and its columns
(on of which is date). The web services sources the data from a sql
server database and thru ASP.net to the Flex application. I've been
seeing strange things. During testing, database records such as
"8/27/2008 8:58:00 PM " correctly shows up as 8/27/2008 in the Flex
application, but records after 9PM such as "8/27/2008 9:01:21 PM"
shows up as 8/28/2008 (the next days) .. seems like after 9 throws
off the data rendering.. please suggest.Adobe Newsbot hopes that the following resources helps you.
NewsBot is experimental and any feedback (reply to this post) on
its utility will be appreciated:
Flex 3 - Handling service results:
Flex interprets the XML data that a web service or HTTP
service returns to ..... a DataGrid control with DataTable data
returned from a .NET web service.
Link:
http://livedocs.adobe.com/flex/3/html/data_access_6.html
Flex cookbook beta - Building Flex Applications with SOAP Web
Services:
Mar 3, 2008 ... If you are using web services technologies
then it is usually ... The DataGrid tag instanciates an instance of
the DataGrid Flex control.
Link:
http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&productId=2&postI d=7863
Flex 3 - Using WebService components:
The Flex web service API generally supports Simple Object
Access Protocol (SOAP) ... property of a DataGrid control and
displayed in the DataGrid control.
Link:
http://livedocs.adobe.com/flex/3/html/data_access_3.html
Adobe - Flex General Discussion:
Flex datagrid data column / webservice - justneed2know -
08/27/2008 ... I use a web service to populate a datagrid and its
columns (on of which is date).
Link:
http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=60&catid=585&threadid =1388794&enterthread=y
All Classes (Flex 3):
mx.rpc.soap, AbstractWebService is an abstract base class for
implementations that provide RPC access to SOAP-based web services.
Link:
http://livedocs.adobe.com/flex/3/langref/class-summary.html
Adobe - Developer Center : Using Flex Builder to Create Web:
Using Flex Builder to Create Web ServiceBased Flex
Applications ... The web service result data needs to flow to the
DataGrid. Select the 'Data will flow
Link:
http://www.adobe.com/devnet/flex/articles/flexbuilder_ws_04.html
Disclaimer: This response is generated automatically by the
Adobe NewsBot based on Adobe
Community
Engine. -
Can i extend the Flex DataGrid using ActionScript and create as Add-On Component ?
I've been trying to get this to work. But i'm having issues Not sure if it's related to the Array binding limitation mentioned in the release notes. Maybe someone else has some ideas.
I'm trying to bind to the dataProvider property of the DataGrid. That way when the user in Xcelsius selects a range, it will bind the data in the excel sheet to the DataGrid.
Problem is that i'm only getting one value to update (specifically the top value). At this time i'm only trying to bind a single column of data.
I noted that the commitProperties function gets called whenever a cell changes that i'm bound to, but the dataProvider is only receiving the first value of the array. Even odder is that the ArrayCollection that i receive simply looks like this:
commitProp:dataProvider=(mx.collections::ArrayCollection)#0
filterFunction = (null)
length = 1
list = (mx.collections::ArrayList)#1
length = 1
source = (Array)#2
[0] 1
uid = "A37C62CC-F3DC-E1B1-8159-CE984C2CCE33"
sort = (null)
source = (Array)#2
So i see that i get an array collection of ArrayList objects, the first one of which simple contains the value in the excell sheet "1".
I noted that the proxy.bind function has a parameter called "chain", maybe this is what i need to get multiple value binding? The documentation for the calls are pretty basic, which is understandable as this is new technology.
So anyone have some ideas? Maybe someone from BO who is apart of the SDK group can comment? -
Showing multiple links from inside a flex datagrid button
Hi,
I have a requirement where I need to show a button inside
flex datagrid column.Which I'm doing with custom itemrenderer.When
the User clicks on a particular button inside data grid I need to
show him multiple links with images where user cal click on one of
the links if he choses to do so.How do I achieve this.Any example
is greatly appreciated.
Regards
mflex."...show him multiple links with images ..." Where/how does
this need to be displayed?
Tracy -
Flex DataGrid with Dynamic Grouping
Does anyone know of any examples of Flex datagrids that have
grouping features comparable to the numerous grid components
available in the ASP.NET world? I’m thinking of .NET
component vendors such as Telerik, Infragistics, Component Art,
DevExpress, etc.
The way these .NET controls generally work is that you drag
the header of a column to a bar above the grid, which causes the
grid to redraw based on the new grouping you just specified.
This is an example of a grid component that I am currently
using:
Telerik
Grid
Thank you,
Mike ChabotThe renderer's data property is the data for the entire row so you can get the column1 data and assign the combobox's dataprovider accordingly.
Alex Harui
Flex SDK Developer
Adobe Systems Inc.
Blog: http://blogs.adobe.com/aharui -
Sort column in advanceddatagrid
Hi, i have an interesting question - how to sort column id
datagrid, like i clicked on a header. I use AdvancedDataGrid and
HierarchialDataYes, it works for HierarchicalCollectionView, but works for
only first level of the tree. Like I sort an XMLListCollection,
comparefunction handles only full elements of the first level. I
need also to sort children nodes of the thee (customer wants).
I have done it for XMLListCollection which is the source of
HierarchialData but it's too many letters =)) and i need sort it
and refresh HierarchialData after every change. Advanced datagrid
makes it automatically by pressing on a header.
Here is the code:
quote:
public static function
sortXMLListCollection(xml:XMLListCollection,dataField:String):XMLListCollection
var sorting:Sort=new Sort();
sorting.fields=[new SortField(dataField)];
xml.sort=sorting;
xml.refresh();
for each(var item:XML in xml)
XMLUtils.sortXMLNode(item,sorting);
return xml;
public static function
sortXMLNode(node:XML,sorting:Sort):XML
var tempXML:XMLListCollection=new XMLListCollection(node.*);
tempXML.sort=sorting;
tempXML.refresh();
XMLUtils.clearNode(node);
XMLUtils.appendXMLListInXML(node,tempXML.copy());
for each(var item:XML in node.*)
XMLUtils.sortXMLNode(item,sorting);
return node;
public static function
appendXMLListInXML(xml:XML,xmlList:XMLList):XML
for each(var appendXML:XML in xmlList)
xml.appendChild(appendXML)
return xml;
public static function clearNode(xml:XML):XML
for(var i:int=new
XMLListCollection(xml.*).length-1;i>=0;i--)
delete xml.*
return xml; -
Flex datagrid borders off by 1px?
Is there a way to extend the datagrid component or any to her way to avoid this?
Flex datagrid column header borders and column borders keep going off by 1px... and they randomly alternate when resized.
I have no idea how to fix this, and it to me looks like a problem with flex, not so much what i coded
http://screencast.com/t/NmI3Zjk0NmU
http://screencast.com/t/YzE0NDk5 - resized
It's like it's going off by 1px because of some rounding error... no idea why this is happening, and I'm using
Code I'm using (a bit sloppy but still)
http://pastebin.ca/1888773I could use someone's help on this... Every single datagrid i create (at least with a custom header gradient, I think), has borders off by 1px, what can I do to fix this? I've even seen this happening on other sample flex projects. No idea how to fix this
-
Hi
I am using a flex datagrid component which has around 48 columns.
There is a option for the user to select which columns he wish to see.
Based on the user's selection the visible columns will be 1-50.
The Datagrid is inside a Vbox container.
The issue is, based on the screen resolution and the number of columns selected extra scroll bars(horizontal and vertical) appears
for the whole Vbox in addition to the Datagrid's scrollbars.
i.e if resolution is high and user selects more than 46 columns extra scroll bar appears.
If resolution is low the extra scroll bars appears as soon as the visible columns is more than 20.
Please help me if there is any resolution in preventing the extra scroll bars from appearing.Ideally, Since datagrid has its own scroll bars making more columns visible should not increase the width of datagrid.
Any help will be appreciatedHave you hard-coded the height and width of both the VBox and the Datagrid? If you set the datagrid height and width 40 pixels or so less than the VBox it should solve that problem, I'd think.
Or, you could set your DataGrid height and width to 90%.
Sorry if you've already tried this. Another option is to set your datagrid's scroll policy to "off" and just leave the VBox's scroll bars available.
-John -
Flex datagrid data on datachange
Hi all,
I am using an extended datagrid which takes its height on the basis of measured height of items. Item renderer for datagrid is a canvas. Which holds one more canvas(header for item renderer) and a text area. The problem I am facing is with the header canvas in item renderer. Header canvas has one label which diaplay a name of user. On the basis of data provider for the current item visibility of this label in header canvas is set as true or false. issue is when it set to false it repaints(on data change event) all the previous header canvas label also to visible false. And just the last item has the data. Rather it should set its visiblity false only for the current item and rest items sholud behave as value set for them.
Thanks in advance.Adobe Newsbot hopes that the following resources helps you.
NewsBot is experimental and any feedback (reply to this post) on
its utility will be appreciated:
Flex 3 - Handling service results:
Flex interprets the XML data that a web service or HTTP
service returns to ..... a DataGrid control with DataTable data
returned from a .NET web service.
Link:
http://livedocs.adobe.com/flex/3/html/data_access_6.html
Flex cookbook beta - Building Flex Applications with SOAP Web
Services:
Mar 3, 2008 ... If you are using web services technologies
then it is usually ... The DataGrid tag instanciates an instance of
the DataGrid Flex control.
Link:
http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&productId=2&postI d=7863
Flex 3 - Using WebService components:
The Flex web service API generally supports Simple Object
Access Protocol (SOAP) ... property of a DataGrid control and
displayed in the DataGrid control.
Link:
http://livedocs.adobe.com/flex/3/html/data_access_3.html
Adobe - Flex General Discussion:
Flex datagrid data column / webservice - justneed2know -
08/27/2008 ... I use a web service to populate a datagrid and its
columns (on of which is date).
Link:
http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=60&catid=585&threadid =1388794&enterthread=y
All Classes (Flex 3):
mx.rpc.soap, AbstractWebService is an abstract base class for
implementations that provide RPC access to SOAP-based web services.
Link:
http://livedocs.adobe.com/flex/3/langref/class-summary.html
Adobe - Developer Center : Using Flex Builder to Create Web:
Using Flex Builder to Create Web ServiceBased Flex
Applications ... The web service result data needs to flow to the
DataGrid. Select the 'Data will flow
Link:
http://www.adobe.com/devnet/flex/articles/flexbuilder_ws_04.html
Disclaimer: This response is generated automatically by the
Adobe NewsBot based on Adobe
Community
Engine. -
How can i change the default sort Arrow Color in the datagrid?
How can i change the default Sort Arrow Color in the
datagrid? i didnt found any style properties to change the sort
arrow color, i know it can be do it in flex 1.5 but how to do it in
flex2?Type about:config in the address bar. Find browser.download.dir and change it to the path you want. Remember that Android has a linux base so the path will similar to /mnt/sdcard/downloads/
Maybe you are looking for
-
10g grid control installation (hanging problem) on RHEL AS 4.0
Iam trying to install enterprise manager 10g(10.2.0.1.0) grid control on RHEL AS 4.0. At a stage after specifying security options the OUI hangs for long time (for about 15 mins) then it works fine till 100% installation then hanged for all day which
-
Dear fourmites, I am using the log4j to log messages to files. File is getting created but my logger messages like logger.info("alaas"); are getting printed on console but not in file. Can any one plz tell me the solution. My code is as follows. pack
-
Anyone Ever Seen This Before?
Hello, Has anyone ever seen this before: http://digitalmarketing1.com/MacErrorPicture.jpg Running an IMac Intel Core 2 Duo 2.33 GHz, Microsoft Entourage 2004 for Mac v 11.3.6. Opened Entourage and selected some of the tons of spam > hit Delete and th
-
Implementation of complex strategy methodology
Hello experts, I have read all of the forum threads and didn't find the answers. We are in need to estimate does the SAP SMM will fit for certain strategy methodology. The methodology is used in public sector and is approved by the local government.
-
Production Order Component long text
I'm an ABAPer trying to find the long text of a production order component. I'd expect to find it as a text with object "AUFK" id "MATK" but that's not the case. I can't find it anywhere in table STXH where it would show up if it were kept like any o