Sort Direction in Data Grid

Hi
i want to know if the clicked column is sorted ASC or DESC,
While debugging step by step, i found a property in dataGrid whis is "sortDirection"
but this property is not accessible like this "dataGrid.sortDirection"
is there any method to access this property.
thank you

Hi, for using that kind of property you have to use 'mx_internal'.
I am putting the code here which can explore you mutch better.
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
import mx.collections.*;  
import mx.core.mx_internal;  
use namespace mx_internal; [Bindable] 
public var ac:ArrayCollection = new ArrayCollection([ {No:'1', Name:'Charl' },{No:
'2', Name:'Mark' },{No:
'3', Name:'James' },{No:
'4', Name:'Robin' }]);
private function onCreationComplete(): void{
dg.mx_internal::sortDirection ="DESC" ;}
]]>
</mx:Script>
<mx:DataGrid id="dg" width="350" height="200" dataProvider="{ac}" creationComplete="onCreationComplete()">
<mx:columns>
<mx:DataGridColumn dataField="No"/>  
<mx:DataGridColumn dataField="Name"/>  
</mx:columns> 
</mx:DataGrid>
Hope it will help you.
with Regards,
Shardul Singh Bartwal

Similar Messages

  • Sort functionality in Data Grid

    Hi Gurus,
    I am new to this DataGrid control.I want to establish the sort functionality when clicking on the headercolumns as in matrices.
    (ie.When double clicking the header column , sort the data in ascending or descending order of that column) like in system form matrices.
    How ever this is not possible when I tried with grid control.
    The problem I am facing is that I cannot get the column headers of the grid programmatically.(in duble click event or itempressed event)
    Anybody did this one previously? Also how
    we can change the column order of the grid using screen painter?
    The columns that actually come visible in the grid  are actually columns of the linked datatable object.
    In the designer ,there is no "swap" button for column re-ordering.
    Only one way I know is changing the query associated with datatable.
    This is a crucial thing ,since client may ask for re-ordering of columns frequently.
    Can anybody help?
    Regards,
    Deepesh

    Hi Deepesh,
    1. This functionality is not available with the SDK. Thus it's not possible to change it on the fly. Your only option is to change the query associated with datatable (as you mentioned). You may set up a user preference table, that the user can configure with its preference. That's the best you can do.
    2. To swap the columns in screen painter you must use SBO 2005 (it's not available on previous release). What you must do is, click on the one column you want to swap and the other you want to swap and click on the swap button (on the left bottom of the page in the columns tab)

  • Sort on views in data grid (ORA-00904)

    Can anyone else confirm that this happens, or has been highlighted previously:
    1. Connect to any schema containing views
    2. Expand the views tree
    3. Click on any view
    4. Click on the data tab to display the data grid
    5. Click the sort button
    6. Select any column (must not exist in view selected later)
    7. Click "Apply Sort"
    8. Now click on any other view that does not contain a column of the same name as the one chosen as the sort column previously.
    I receive an ORA-00904 error. The only way I can clear this is to close down the data grid tab item, and re-open it.
    Cheers
    Carl
    DBA - Dunfermline Building Society

    Yes.
    Login as a DBA.
    Go to Other Users - SYS - Views - More - Filter - %% - OK
    Click on DBA_USERS - DATA - Sort - USERNAME - Apply Sort
    Click on DBA_USTATS
    --> ORA-00904 "USERNAME". invalid identifier.
    Notice that the columns in the data view have not changed.
    Close the tab and click on DBA_USTATS fixes the problem (no data anyway).
    Click on freeze view (the push pin) and click on DBA_USTATS fixes the problem.
    These are two easy workarounds, but it is confusing the first time you encounter it.

  • Advanced Data Grid Sorting / Grouping Collection

    Ok, basically here's the issue..
    I have an advanced data grid with a tree view. It goes two
    levels deep
    so:
    Report Type
    |-------------------- Company
    |--------------------------------------- Report 1
    |--------------------------------------- Report 2
    |--------------------------------------- Report 3
    |-------------------- Company 2
    |--------------------------------------- Report 1
    |--------------------------------------- Report 2
    |--------------------------------------- Report 3
    Report Type 2
    |-------------------- Company
    |--------------------------------------- Report 1
    |--------------------------------------- Report 2
    |--------------------------------------- Report 3
    |-------------------- Company 2
    |--------------------------------------- Report 1
    |--------------------------------------- Report 2
    |--------------------------------------- Report 3
    etc..
    Report and Company are Nodes (folders) and are being sorted
    alphabetically by default.
    The individual reports (Report 1,2,3, etc..) are not being
    sorted in any way that I can figure out. I need to sort them by
    date, but no matter what I've tried I can't get it to work.
    I tried a SortCompareFunction on the advancedDataGridColumn
    that displays each report, and it works *IF* I click the header...
    but if I dispatch the header_release event via AS3, nothing
    happens.
    I even set up a test:
    dg.addEventListener(AdvancedDataGridEvent.HEADER_RELEASE,heard);
    dg.dispatchEvent(
    new AdvancedDataGridEvent
    AdvancedDataGridEvent.HEADER_RELEASE,
    false,
    true,
    0, // The zero-based index of the column to sort in the
    DataGrid object's columns array.
    null,
    0,
    null,
    null,
    0
    function heard(e:Event) {
    trace("I HEAR IT!");
    trace(e.type);
    I set that up on a button so I can dispatch the event with a
    click. Every time I click the button, the header release event
    listener goes off, but the actual advanceddatagrid remains
    unchanged until I actually click on it's header..
    Any help would be *GREATLY* appreciated... I've been stuck on
    this problem for two days now :(

    "AnakinJay" <[email protected]> wrote in
    message
    news:[email protected]...
    > Ok, basically here's the issue..
    >
    > I have an advanced data grid with a tree view. It goes
    two levels deep
    > so:
    > Report Type
    > |-------------------- Company
    > |--------------------------------------- Report 1
    > |--------------------------------------- Report 2
    > |--------------------------------------- Report 3
    > |-------------------- Company 2
    > |--------------------------------------- Report 1
    > |--------------------------------------- Report 2
    > |--------------------------------------- Report 3
    >
    > Report Type 2
    > |-------------------- Company
    > |--------------------------------------- Report 1
    > |--------------------------------------- Report 2
    > |--------------------------------------- Report 3
    > |-------------------- Company 2
    > |--------------------------------------- Report 1
    > |--------------------------------------- Report 2
    > |--------------------------------------- Report 3
    > etc..
    >
    > Report and Company are Nodes (folders) and are being
    sorted alphabetically
    > by
    > default.
    > The individual reports (Report 1,2,3, etc..) are not
    being sorted in any
    > way
    > that I can figure out. I need to sort them by date, but
    no matter what
    > I've
    > tried I can't get it to work.
    >
    > I tried a SortCompareFunction on the
    advancedDataGridColumn that displays
    > each
    > report, and it works *IF* I click the header... but if I
    dispatch the
    > header_release event via AS3, nothing happens.
    >
    > I even set up a test:
    >
    dg.addEventListener(AdvancedDataGridEvent.HEADER_RELEASE,heard);
    >
    > dg.dispatchEvent(
    >
    > new AdvancedDataGridEvent
    > (
    > AdvancedDataGridEvent.HEADER_RELEASE,
    > false,
    > true,
    > 0, // The zero-based index of the column to sort in the
    DataGrid object's
    > columns array.
    > null,
    > 0,
    > null,
    > null,
    > 0
    > )
    >
    > );
    >
    > function heard(e:Event) {
    >
    > trace("I HEAR IT!");
    > trace(e.type);
    >
    > }
    >
    >
    > I set that up on a button so I can dispatch the event
    with a click. Every
    > time I click the button, the header release event
    listener goes off, but
    > the
    > actual advanceddatagrid remains unchanged until I
    actually click on it's
    > header..
    >
    > Any help would be *GREATLY* appreciated... I've been
    stuck on this problem
    > for
    > two days now :(
    Check the compareFunctions here
    http://flexdiary.blogspot.com/2008/09/groupingcollection-example-featuring.html

  • Data Grid Sort Within Portlet

    I have a portal with a portlet that contains a search form and a data grid. I have set the sortable attribute on the column to true. The sort action gets the filter service and passes it to the DB control.
    I cannot seem to get the sorting to work. The output from getSortFilterService().getDatabaseFilter(getGridName()).getOrderByClause() is always empty no matter which column I click.
    Is there something special I have to do because of the portal/portlet?
    Can someone give me a tip (or two). I realize this is a novice question but I am learning as I go and would appreciate any help.
    Edited by markml at 09/20/2007 9:41 PM

    I figured it was locking up the browser. I submitted a bug ticket several months ago concerning the same issue. If you have "enableviewstate" set to true on a datagrid and you are using the PT web controls, then the browser will lock up. It all depends on the number of rows and columns you have in the datagrid; unfortunately, I don't know the fatal number.
    However, what causes it is how Plumtree manages the viewstate itself for a datagrid. In a nutshell, they have to remember the viewstate for each single item in the grid. And the algorithm they use is extremely slow. The browser's scripting engine basically locks up because of the length of time it takes.
    Unless you absolutely need it, I would just turn off the viewstate. It disables some fancy features of the datagrid, but you can still build workarounds.
    Hope this helps/clarifies things for you!
    --JasonFTN Financial

  • Data Grid Control +JSP+Sorting

    Hi,
    Can any one help me regarding In JSP by using Data Grid Control to sort columns in table and displayed in same JSP.

    Yes! We can help! Do you have any other questions?
    Edited by: SoulTech2012 on Sep 20, 2008 11:51 AM

  • Custom sorting in data grid

    Sorting entire records
    Problem:
    Assume you have an array of 20 items (master array), and
    first 5 items are pulled into another array (paged array),
    Which is the dataprovider for the datagrid. And the datagrid
    has 10 columns.
    When the user sorts on the datagrid, sorting should happen on
    the 20 records, and
    Not on the 5 records.
    What i tried:
    Clicking on a datagrid column header will sort only the data
    provider of the datagrid. i.e., the
    5 records. In order to sort all 20 records, sorting should
    take place on the master array,
    and not on the paged array. Sorting on 20 items seems to be
    impossible.
    The only logic we could think of was that, on the
    headerRelease of datagrid, capture the
    column header clicked(not sure if you can capture it or not).
    And write custom function
    for sorting based on that column. Since there are 10 columns,
    the number of functions
    or number of blocks of code to be written will Be 10. So did
    not feel to be feasible and optimal solution.
    Please advice.

    Hello chhavs,
    If you listen to the DataGrid's headerRelease event, the event has a property columnIndex to let you know which column the user wanted to sort. So you don't need 10 functions, just one with a switch statement, which is reasonable.
    private function handleHeaderRelease(event:DataGridEvent):void
    var sort:Sort = new Sort();
    var field:SortField;
    switch (event.columnIndex)
    case 0:
    field = new SortField("fieldA");
    break;
    case 1:
    field = new SortField("fieldB");
    break;
    case ...
    sort.fields = [field];
    masterRecords.sort = sort;
    masterRecords.refresh();
    Thanks,
    Philip

  • How to access sort direction and filter value of columns?  Can I catch the 'filtered' or 'sorted' event?

    We have some columns being added to a table.  We have set the sortProperty and the filterProperty on each of our columns.
    This allows us to both filter and sort.
    We want to be able to access the columns filter value and sort value after the fact.  Can we access the table and then the columns and then a columns properties to find these two items?  How can I access the sort direction and filter value of columns?
    We would also like to store the filter value and the sort direction, and re-apply them to the grid if they have been set in the past.  How can we dynamically set the filter value and sort direction of a column?
    Can I catch or view the 'filtered' or 'sorted' event?  We would like to look at the event that occurs when someone sorts or filters a column.  Where can I see this event or where can i tie into it, without overwriting the base function?

    Hey everyone,
    Just wanted to share how I implemented this:
    Attach a sort event handler to table - statusReportTable.attachSort(SortEventHandler);
    In this event handler, grab the sort order and sorted column name then set cookies with this info
    function SortEventHandler(eventData)
        var sortOrder = eventData.mParameters.sortOrder;
        var columnName = eventData.mParameters.column.mProperties.sortProperty;
        SetCookie(sortDirectionCookieName, sortOrder, tenYears);
        SetCookie(sortedColumnCookieName, columnName, tenYears);
    Added sortProperty and filterProperty to each column definition:
    sortProperty: "ColName", filterProperty: "ColName",
    When i fill the grid with data, i check my cookies to see if a value exists, and if so we apply this sort:
    function FindAndSortColumnByName(columnName, sortDirection (true or false))
        var columns = sap.ui.getCore().byId('statusReportTable').getColumns();
        var columnCount = columns.length;
        for(var i = 0; i < columnCount; i ++)
            if(columns[i].mProperties.sortProperty == columnName)
                columns[i].sort(sortDirection);

  • Create Report from HFM Data Grid

    Hi All,
    I need to create a report out of the Data Grid created in HFM and then publish that as a PDF. I found the Reporting feature in Manage Documents that uses system reports.
    And if I want a report from a data grid the Data Explorer option has to be selected for Report Type.But in this case I guess I need to create a Report Definition File and then upload it which seems to be complex.
    But am not able to figure out how I can directly take a HFM Data Grid as the source and generate a PDF Report out of it.
    Can this be done using BI Publisher? If so can anyone please provide the steps?
    Or, can it be done using the Financial Reporting Studio ?
    I sincerely appreciate any help!
    Thanks in advance!
    Chella

    select
    decode( abs((sysdate - end_time)-1), (sysdate - end_time)-1, 'TOO LONG AGO', '-' ) "Check" ,
    b.database_name , t.type_qualifier1 , b.host ,
    to_char(b.end_time, 'YYYYMMDD-HH24:MI:SS') , b.time_taken_display , b.output_bytes_display
    from mgmt$ha_backup b, mgmt$target t
    where b.target_guid = t.target_guid
    order by type_qualifier1, end_time;

  • Reading a csv file and bind to a data grid

    hi. doing a school project and been searching. the application reads a csv file from c:\stocklist.csv, and then this in a button called btnLoadData, and now need to read in a data control called DmgDisplayData. do i put the code in the button, or in the
    data grid. been searching, but cannot seem to find any thing. so, where do i put the code, in the data control, and does any one have an example code how to read into the data fields. also need to have one field, able to edit, the other three or four fields,
    read only. can any one help me out. never covered this in the subject, but did do file streams a few years ago in vb, but usin g c#,a dn the help in visual studio, not that helpful, with a blind person using a screen reader, jaws for windows from http://www.freedomscientific.com,
    and using visual studio 2013 community edition. can any one help me out, been searching and trawling about 15 to 20 pages so far, and did try a couple of sites, but could not find, any help. thanks. the application is to read a csv file from a button, and
    load into a data grid, then have a message box, saying file load successful, then have one field, order on as edit, but the other fields, read only, so do i need the navigator buttons, for next, back, previous, etc, and how do i code that as well. not to do
    it for me, want to learn, but maybe some sample code, did do navgiator controls, years ago for a vb project, but need the c # example for that, thanks. then you have a button, Save data, that saves the csv file in the data grid. so can google for that. then
    have a toolbar, with a button saying, Sort Items, a tool strip, and when you click on that button, you have a drop down list, of three items, then a sort button, which will then sort the array in the data grid. so, do i need another form, or just do the combo
    box as an invisible control, then just refrence, that in the toolbar. so need to use th file class and an array, learnt about single and multi arrays. any ideas. thanks.
    http://startrekcafe.stevesdomain.net http://groups.yahoo.com/groups/JawsOz

    Hi Marvin,
    -->where do i put this, in the data grid click event. or in the form load event. thanks.
    You could use this code after you initialize the DataGridView. you could put it in the form load event.
    -->what about how get the tool bar and the combo box and another button, then sort from the combo box on the array for the collumns, for to set focus to the first read collumn for the data grid. how do i do that, close the parent form, and have another
    form on the toolbar.
    Since this is another issue of this thread, I would recommend you posting it with
    another thread. We will focus on that thread to help you. Thanks for your
    understanding.
    BTW, Before you asking questions, I suggest you could learn to make it by yourself. You could begin to learn winforms in MSDN articles:
    https://msdn.microsoft.com/en-us/library/dd30h2yb%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396. Or Google it, you will get many answers. In that way, you will learn more from the questions.
    Best regards,
    Youjun Tang
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • How to avoid blinking / moving of rows in a data grid when you restore the scroll positions

    By Default when an update is made on a data grid, it scrolls to top row. To avoid this when we save the vertical and horizontal scroll
    positions and restore the scroll positions after the update, it causes a blink in the grid (or moving / jumping) of rows. Is there a way to
    avoid this jumping of rows?
    In JavaScript this can be achieved by overriding the scrollToTop / OnLoad methods of datagrid to directly scroll to current scroll
    positions instead of top row. Is there a way to achieve similar feature in flex / actionscript?

    I am calling validateNow().. Also, using verticalScrollPosition to restore the scroller as in the link that you posted.. Reposition is working fine, But the bug filed is regarding BLINKING / JUMPING when this happens (i.e. this blinking is caused because after datagrid edit, during reload the scroller tries to move to  the top by default, then it repositions itself to current edited row as the verticalScrollPosition property is overridden ).. I have to get rid of this blinking.
    In Javascript it is dealt by overriding OnLoad method of datagrid to directly scroll to current scroll position instead of top row during reload so that there is no blinking.
    http://www.sencha.com/forum/showthread.php?13898-Is-there-any-way-to-keep-scroll-position- of-Grid-on-load
    Is there a way to achieve similar feature in flex?
    I am not sure what flex datagrid method to override.. Theres no method like load? What is the datagrid method that is called by default during reload (after datagrid edit) that causes the scroller to go to top?

  • Sort by Release Date option?

    I don't know why an option to sort by "release date" is absent from iTunes. It seems like an obvious way to layout/view music. There isn't even an option to enter the "Release Date"(only "Year") on music files.
    I use the pattern "Year/Month/Date - Album Name" with in the "Album Sort Order" field to help iTunes sort my Albums by release date. But, within the "Grid View", it doesn't seem to be possible to sort by "album"(which would use the "sort album" field) to see all the albums by release date.
    It just seems like such a basic thing to be added to such a music application.
    It seem like there are a lot of these "little" details which iTunes never seems to add. For example: the ability for iTunes to read and write multiple Genres(& subgenre) entries with in a MP3 IDtag.
    I just don't understand how the devs can neglect such options, which would be valuable for anyone who likes to keep there music properly labelled.
    I wish they would forget silly ideas like PING, and concentrate on trying to make iTunes a deep music browser and management tool, like it should be.
    That's the end of my rant.

    I was talking about "Grid View". I cannot sort my albums by release date within "Grid View".
    But yes, you are correct. Although, in my experience, the issue with using the "Release Date" field is that iTunes seems unable to read some dates correctly.
    For example; I have Bob Dylans album "Times They Are A Changin'", and if I enter the release date(using a 3rd party program because you can't edit the "ReleaseTime" field in iTunes), using the correct format, "1964-01-13" iTunes displays this as "Thu 01/01/70". I know this is the correct format because I can enter a newer date and it will display correctly.
    So it seems iTunes doesn't recognise anything before that date.

  • Is it possible to return a data grid in sql developer from package?

    Hi, I am in need of some help in returning a datagrid rather than just a list from a package. This is my package:
    CREATE OR REPLACE PACKAGE BODY C_1
    as
    PROCEDURE COUNTING1 (C_YEARFROM IN NUMBER, C_TABLE_NAME IN VARCHAR2) is
    yearCount NUMBER;
    c_sql long;
    BEGIN
    execute immediate 'SELECT COUNT(DISTINCT SPECIES) FROM '||C_TABLE_NAME ||' WHERE year >2007' into yearCount;
    dbms_output.put_line('Distinct species count: ' ||yearCount);
    end counting1;
    end c_1;
    Is it possible to get the results of these in a table or data grid in sql developer, e.g. I would like to sort results etc rather than just a flat list? Something a bit more elegant then dbms_output.put_line?
    Thanks

    yes, I copied the wrong code into the example - what I actually want to display in a grid is the following:
    CREATE OR REPLACE PACKAGE RSET_CURSOR IS
    cursor rs_cursor is select species, location from ot;
    r_c rs_cursor%rowtype;
    end;
    create or replace package rset_cursor2
    is
    procedure printSpecies;
    end rset_cursor2;
    create or replace package body rset_cursor2
    is
    procedure printSpecies is
    begin
    open rset_cursor.rs_cursor;
    loop
    fetch rset_cursor.rs_cursor into rset_cursor.r_c;
    exit when rset_cursor.rs_cursor%notfound;
    dbms_output.put_line(rset_cursor.r_c.species);
    end loop;
    close rset_cursor.rs_cursor;
    end;
    end;
    I have also just noticed the list I am getting is only including one column of data where it should include 2, have I omitted something?
    Thanks

  • Custom System Data Grid

    Hi!
    I need a custom data grid, explaining:
    I need to made custom list of specific files, in the System data grid I can use the drag and drop files to desktop, but how I made the drag and drop work in the custom data grid of list of files?
    I tried to show in the data grid the path of the file, and drag this, but the error is:
    "Data for file list format must be an array of Files"
    But, how I made a "array of files"?
    Sorry to my bad english =)
    Thanks a lot! =)

    Hello chhavs,
    If you listen to the DataGrid's headerRelease event, the event has a property columnIndex to let you know which column the user wanted to sort. So you don't need 10 functions, just one with a switch statement, which is reasonable.
    private function handleHeaderRelease(event:DataGridEvent):void
    var sort:Sort = new Sort();
    var field:SortField;
    switch (event.columnIndex)
    case 0:
    field = new SortField("fieldA");
    break;
    case 1:
    field = new SortField("fieldB");
    break;
    case ...
    sort.fields = [field];
    masterRecords.sort = sort;
    masterRecords.refresh();
    Thanks,
    Philip

  • How to click on linkbuttons in the rows of a data grid

    I'm trying to write automation test cases for a flex application using Flex Selenium.
    The flex selenium API provides only 2 click events: click(String objectId) and click(String objectId, String optionalButtonLabel)
    There are no click events for rows or columns for a data grid.
    The application has a  DataGrid with 2 linkbuttons in a column for each row (besides other columns).
    The linkbuttons have an id. But clicking it only clicks the one in the first row.
    Now, I have to perform these tasks:
    - Click on the link buttons in any row
    -  Click on any row
    -  Click on column  header to sort
    How can I accomplish these?

    Hi Suman,
    thanks for your prompt reply.
    I am trying it but it doesn't work. I started to run the query for a while but it is still running and there is no result for it. I still see the variable popup I filled after the first running of the query.
    Any other idea?
    Kind regards,
    Ali

Maybe you are looking for