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?
Marcos

Hi 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

Similar Messages

  • 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.

  • Sorting Columns in Datagrid

    Developing in Flash, AS3.
    I have a datagrid that uses a custom cellrenderer class to allow me to use a combobox. I have an invisible column that holds the value returned by the cellrenderer when the combobox value is changed. BUT sorting is wonky. Since what really lives in the combobox column individual cells is an object, it never really sorts properly. Is there a way to fire a sorting event to the column that holds the real value?
    Thanks in advance!

    Thank you very much for your quick reply. Would you mind providing an example that will work with a combobox?
    Right now, I'm using this bit of code, just to track which cel is being interacted with:
              public function gridItemSelected(e:ListEvent):void {
                   trace ("***");
                   trace( "Row Index: " + e.rowIndex);
                   trace( "Column Index: " + e.columnIndex);
                   var colName:String  =  e.target.columns[e.columnIndex].dataField;
                   trace( "Column Field Name: " +colName);
                   trace( "Cell data: " +e.item[colName]);
                   trace("***");
    which traces out something like this:
    Row Index: 0
    Column Index: 0
    Column Field Name: cname
    Cell data: [object Object],[object Object],[object Object],[object Object],[object Object]

  • Help needed in Sorting Columns (date sorts alphabetically)

    Hi All,
    I have a report query as follows:
    select to_date(period,'MON-YYYY') start_date
    ,exp_type
    ,id
    ,acct_ref
    ,dept_ref
    ,item_date
    ,amt
    from test;
    I need to display the report in the same order as select statement (start_date,exp_type,id etc). I have given default sort order in report attributes and user enabled sort on all columns. The report attributes look as shown below:
    column_name / sort / sort_seq
    start_date / yes / 3
    exp_type / yes / 1
    id / yes / -
    acct_ref / yes / -
    dept_ref / yes / 2
    item_date / yes / 4
    Now my problem is that the start date sorts alphabetically (as varchar) instead of chronologically (date wise). How can I resolve this?
    If I change my default sort order so that start_date is sorted 1st, it works perfectly fine. Is there any restriction for APEX sort that says the column displayed needs to be sorted in the same order? How do I overcome it? Or is it possible to overcome it?
    Any suggestions would be appreciated.
    Thanks,
    Sumana

    Hi,
    Thanks. But no I cannot change it to date, as there are many applications using it for displaying the period. But I found an equivalent date column for that period and tried using that. It was not working.
    I did further analysis and found that even to_char(period) works fine. The problem was something else. In my region query the select statement was
    select exp_type
    ,id
    ,amt
    ,to_date(period,'MON-YYYY')
    from test.
    I then had in region attributes used the arrows to change order of display, so that period appears first. That was the culprit. When I change my region query, to match the order in region attributes the date column as well as to_date(period) both work fine.
    I never knew that the order of select statement and that in region attributes should match each other!!! And hence when posting I did not give importance to the order of my select list. Sorry for that.
    The mystery is how was it working when i changed the sort order to say "period" 1st and then exp_type (2nd)
    Thanks everyone for you help.
    Thanks,
    Sumana

  • 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
    HierarchialData

    Yes, 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;

  • Custom Sort (by date) in a DataGrid component

    So I've got a data grid component hooked up to a data provider like so:
    var weekData:XML=// some xml loaded in earlier....
    var weekGrid:DataGrid=new DataGrid();
    var dataProvider:DataProvider=new DataProvider();
    for each(var entry:XML in weekData){
         dp.addItem({event:entry.title,date:FormatDate.format(new Date(entry.@startDate),5),data:entry.@startDate});
    The title column is just what you might think. The date colum is actually a format like May 2012 or Feb 2013. And the data "column" isn't actually shown in the dataGrid it is the "key" for sorting by date. It contains the getTime() value of the date like 1328515200000. So that will make date sorting just a case of Array.NUMERIC with the appropriate Array.DESCENDING when needed.
    I've found that if I do this:
    weekGrid.dataProvider.sortOn("data",Array.NUMERIC)
    weekGrid.invalidate();
    it works and the grid is sorted -- IF I have some other button to click to cause that code to run.
    I want to tie it together with the click event on the grid header. Thusly:
    weekGrid.addEventListener(DataGridEvent.HEADER_RELEASE,sortDataGrid);
    And I've getting the event and all, but evidently that is fireing off the built-in sorting which happens after mine. And it doesn't do what I want.
    Any idea how to stop that and allow my perferred sorting to take place?

    if you don't want the user to sort your datagrid, use:
    weekGrid.sortableColumns = false;
    and execute your sort without clicking anything.  or use:
    weekGrid.addEventListener(DataGridEvent.HEADER_RELEASE,sortDataGrid);
    function sortDataGrid(e:DataGridEvent):void{
        setTimeout(sortF,100);
    function sortF():void{
        weekGrid.dataProvider.sortOn("data",Array.NUMERIC)

  • Fetching column data for clicked DataGrid cell

    I am using a DataGrid and the number of columns are based on the data thus dynamic; columns are added at runtime.  I am trying to use the same ItemRenderer for all columns.  The one piece I can not seem to get to work is knowing which datafield to use to populate each column.  I have tried getting the column.dataField from the current datacolumn to no avail; sample code listed below.  This is my first Flex project so my approach to the problem may not be the best; please alert me if this is the case.  I would appreciate any help you could lend.
                    var dgListData:DataGridListData = listData as DataGridListData;
                    var dataGrid:DataGrid = dgListData.owner as DataGrid;
                    var column:DataGridColumn = dataGrid.columns[dgListData.columnIndex];
                    var dataField = column.dataField;
                    var lbl:Label = new Label();
                    lbl.text = value[dataField];    // must add based on previously named source field; dataField
    ce

    Update:
         A few more details...
    I am trying to do this inside of override public function set data(value:Object):void {}

  • 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

  • I have downloaded and installed the latest version of numbers on my mac. Everytime I save and then try to reopen that document, I receive a message telling me that I need a new version of numbers. Also, when I try to sort the date column, it sorts out of

    I have downloaded and installed the latest version of numbers on my mac. Everytime I save and then try to reopen that document, I receive a message telling me that I need a new version of numbers. Also, when I try to sort the date column, it sorts out of order. The last version sorted fine.

    Welcome to Apple Support Communities
    When you install the new iWork version, the old iWork version is kept, so it looks like you are opening your old version.
    To fix this, open a Finder window, choose Applications in the sidebar and drag the new Numbers version to the Dock, so you can access to it quickly. Open all documents from this version. I don't recommend you to delete the old Numbers version in case you need it.
    Respecting to the second question, you will get better answers in the Numbers for OS X forum

  • Import CSV/Excel data into Flex Datagrid using Java/JSP

    Hi,
    Is there any way we can import excel/csv data into flex datagrid component.
    I see that is been done using php in this site. http://code.google.com/p/as3xls/
    Any help would be appreciated.
    Thanks in advance

    You can store the list of data from the Excel sheet that you have read already into an ArrayList
    Then go through the JDBC tutorial, and learn how to insert a single record into the table.
    After you understand how to insert a single record, you can iterate through the ArrayList of data and insert them into the table in the database.
    If you know JDBC, see if you can use OR Mapping frameworks like Hibernate or iBatis, they make it very easy to manage database in Java.

  • Sorting by date in columns cross tab report.

    Hi all,
    I am working on a cross tab report in BI Publisher in which columns are generated dynamically in a pivot table depicting months as Jan 09 , Feb 09.... but data type is char.When displayed in pdf, columns are generated sorted alphabetically.
    How can I have them sorted by date in final pdf?
    or
    How can I stop the columns being sorted in pivot table at template level?
    Thanks.
    Edited by: user9061488 on Jul 21, 2010 1:13 AM

    You need to get a extra column in the query just for sorting purpose, which will have month number in it or YYYYMMDD. format, so that , it can be used in only for sorting.
    with JAN 09, FEB 09 , we can do it, but it will be little complex

  • Rdl file Tablix sorting. dynamical data columns.

    Hi ,
    we are having Tablix with 5 columns of data. in that first 3 column data is a static and remaining two columns data will be calculated and populated dynamically on the 4,5 column. it is working fine but when i sort the any of the first 3 columns it is showing
    the wrong data in the 4,5 th columns.
    can any one help how to over come this.
    Advance thanks.
    Vijay

    Hi Vijay,
    If I understand correctly, the values in the fourth and fifth column change dynamically based on the static values in the first three columns in your report. And then you set the sort expression for the data region or for each group, including the details group
    in a tablix data region.
    I tested the issue in my test environment in the basis of my understanding. I have set the expression in the fourth and fifth column and set the sorting of tablix based on the fifth static column. When running the report, there is no issue.
    To resolve your matter, please post the report design and the expression in sorting option’s screenshot to the forum.
    Regards,
    Heidi Duan
    Heidi Duan
    TechNet Community Support

  • DataGrid header functionality to manipulate column data

    I have been displaying information for individual series in a chart via a datagrid so that the user can edit it (change color, series style, etc.) And it works fine, but now I need to add in some functionality in the header of the series style column.  Basically the user needs to be able to "override" each entry to make all of the series types lines or area or plot or whatever he chooses in the header.  In my research on the net, it looks like I may have to use AdvancedDataGrid to do this.  Does anyone know how I would do this.
    Here's what I have so far.  I've left out most of the other columns for simplicity.
    <mx:DataGrid id="seriesTable" color="black" fontSize="9" rowHeight="30" editable="true" resizeEffect="slow" rollOverColor="#CCCCCC"
    selectionColor="#999999" dataProvider="{axis.seriesList}" width="100%"
    rowCount="{axis.seriesList.length > 2 ? axis.seriesList.length : 2}" >
      <mx:columns>
             <mx:DataGridColumn width="40" dataField="color" headerText="Color" id="colorColumn"
                        rendererIsEditor="true"  editorDataField="result" itemRenderer="renderer.ColorPickerRenderer"/>
             <mx:DataGridColumn dataField="plotType" width="220" id="plotColumn"
                       rendererIsEditor="true"  editorDataField="result" itemRenderer="renderer.TypeBoxRenderer"/>
          </mx:columns>
    </mx:DataGrid>
    (I could also include TypeBoxRender code but I don't think it's really needed to understand what is going on here.)

    I have been displaying information for individual series in a chart via a datagrid so that the user can edit it (change color, series style, etc.) And it works fine, but now I need to add in some functionality in the header of the series style column.  Basically the user needs to be able to "override" each entry to make all of the series types lines or area or plot or whatever he chooses in the header.  In my research on the net, it looks like I may have to use AdvancedDataGrid to do this.  Does anyone know how I would do this.
    Here's what I have so far.  I've left out most of the other columns for simplicity.
    <mx:DataGrid id="seriesTable" color="black" fontSize="9" rowHeight="30" editable="true" resizeEffect="slow" rollOverColor="#CCCCCC"
    selectionColor="#999999" dataProvider="{axis.seriesList}" width="100%"
    rowCount="{axis.seriesList.length > 2 ? axis.seriesList.length : 2}" >
      <mx:columns>
             <mx:DataGridColumn width="40" dataField="color" headerText="Color" id="colorColumn"
                        rendererIsEditor="true"  editorDataField="result" itemRenderer="renderer.ColorPickerRenderer"/>
             <mx:DataGridColumn dataField="plotType" width="220" id="plotColumn"
                       rendererIsEditor="true"  editorDataField="result" itemRenderer="renderer.TypeBoxRenderer"/>
          </mx:columns>
    </mx:DataGrid>
    (I could also include TypeBoxRender code but I don't think it's really needed to understand what is going on here.)

  • Keep sorting and sort arrows after datagrid dbprovider changed

    I followed this tutorial http://justinjmoses.wordpress.com/2008/06/26/flex-keeping-the-sort-on-a-datagrid-when-you- change-the-dataprovider/
    created listeners
    that keeps old sorting of datagrid after dataprovider changed, but displaying sort arrow on the wrong column(always the 1st column), how do I fix it?
                       //constructor
              public function FilterDatagrid()
                   super();
                   addEventListener(mx.events.CollectionEvent.COLLECTION_CHANGE, onDataGridDataChange, false, 0, true);
              private var currentSort:mx.collections.Sort;
              private function onDataGridDataChange(evt:CollectionEvent):void
                   //get the new data collection
                   var ac:ArrayCollection = this.dataProvider as ArrayCollection;
                   //attach the collection change event
                   ac.addEventListener(CollectionEvent.COLLECTION_CHANGE, onCollectionChanged,false,0,true);
                   //if a sort was in place before the data was changed, make sure you apply the sort to this new data
                   if (currentSort != null)
                        ac.sort = currentSort;
                        ac.refresh();
              private function onCollectionChanged(evt:CollectionEvent):void
                   if (evt.kind == CollectionEventKind.REFRESH)
                        var ac:ArrayCollection = evt.currentTarget as ArrayCollection;
                        currentSort = ac.sort;

    the datagrid uses XML as dataprovider and uses labelFunction and sortCompareFunction on each column, not sure if it matters

  • About the row number of the datagrid[Flex 2.0 beta3]

    I want to add a column to the datagrid,which will indicates
    the row number.Who can tell me how to do it?
    And how to keep the number's sequence unchanged when the
    header of one of other columns is cliked to sort the
    data?

    If I understand this correctly. Then would it not make more
    sense to say in
    the LiveDocs --
    makeObjectsBindable - After the remote call (RPC, HTTP, SOAP,
    etc) returns
    its value. Flex tries to automatically convert the result
    into an
    ArrayCollection (if it looks like an array, even if it was
    XML) [Or
    others???] format. This automatic conversion controlled by
    the
    makeObjectBindable property. If false, Flex does not attempt
    the conversion
    and the result will be in (xml?) format.
    "peterent" <[email protected]> wrote in
    message
    news:eali1i$1q9$[email protected]..
    > Results that come back which look like Arrays will be
    turned into
    > ArrayCollections automatically. Since most people
    immediate turn an Array
    > into
    > an ArrayCollection, we went ahead and did it for you.
    Try getting rid of
    > your
    > new ArrayCollection in the result handler.
    >

Maybe you are looking for

  • Unable to load Driver Class

    Hi There: When I try to connect to the Oracle 8i via this applet , I get the following run time error. Any help will be appreciated. I am using j2sdkee1.3.1, jdk1.3.1_02 and Oracle8. I also need your suggestion please. I have inserted some BLOB data

  • One JFrame At A Time

    I have a JFrame made up of various boxes When the user clicks on a box, a mini-JFrame pops up. So every time the user clicks on a box a mini-JFrame will appear. Is it possible to make sure that only one mini-JFrame appears at a time? So what I pterry

  • How do i save raw images on hard drive

    after i have worked on a RAW file how do i save it to my hard drive for future transmission as a RAW file?

  • "Unrated or better" shows no photos in browser after Lion upgrade

    After upgrading to Lion I have found my Aperture library isnt working as it used to.  At first I thought I lost all of my photos, but am able to reveal them in my library under photos, but not within the projects. If I click into a project say "Weddi

  • Where to place my customed mbean jar file?

    Hi all, I am totally new to weblogic, and our server is version 6.1. I would like to know where should I place my mbean class jar file? Mike