Datagrid labelfunction sort problem

I have a problem with sorting on all columns the moment I
implement a labelFunction in a datagrid. When I click the datagrid
headers nothing happens anymore. I need the labelFunction in the
first place to format some data.
Does anyone has a solution for my problem?
Here's the code (fragmented):
<mx:DataGrid id="dgUsers" dataProvider="{aUsers}">
<mx:columns>
<mx:DataGridColumn headerText="number"
labelFunction="dispUsers"/>
<mx:DataGridColumn headerText="name"
labelFunction="dispUsers"/>
<mx:DataGridColumn headerText="role"
labelFunction="dispUsers"/>
</mx:columns>
</mx:DataGrid>
private function dispUsers(item:Object, column:
DataGridColumn):String {
switch(column.headerText) {
case "number":
return item.username;
case "name":
return formatName(item.voornaam, item.tussenvoegsel,
item.achternaam);
case "role":
return item.roleName;
default:
return "";
private function formatName(sVoor:String, sMidden:String,
sAchter:String):String {
var sName:String = "";
if(sAchter != "") {
sName += sAchter;
if(sVoor != "") {
if(sName != "") {
sName += ", ";
sName += sVoor;
if(sMidden != "" && sVoor != "") {
sName += " " + sMidden;
return sName;

Because you have a labelFunction, the DataGrid now needs a
sortCompareFunction to tell it how to sort your data. Here is some
extra info.
http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=L iveDocs_Parts&file=00000598.html
Joan Lafferty
Flex SDK QA

Similar Messages

  • Sorting Problem in FND_MENU_ENTRIES_TL Table

    Hi,
    FND_MENU_ENTRIES_TL Table storing the record FND_MENU_ENTRIES_TL_N1(MENU_ID,PROMPT,LANGUAGE) wise in R12. But whereas in 11i, records stored FND_MENU_ENTRIES_TL_U1(MENU_ID,ENTRY_SEQUENCE,LANGUAGE).
    I am confused, whether i need to recreate the index in R12, so the records will get store MENU_ID,ENTRY_SEQUENCE,LANGUAGE wise.
    Could any one please suggest me how to resolve this problem.
    Thanks,
    Praba T

    815667 wrote:
    Hi,
    FND_MENU_ENTRIES_TL Table storing the record FND_MENU_ENTRIES_TL_N1(MENU_ID,PROMPT,LANGUAGE) wise in R12. But whereas in 11i, records stored FND_MENU_ENTRIES_TL_U1(MENU_ID,ENTRY_SEQUENCE,LANGUAGE).
    I am confused, whether i need to recreate the index in R12, so the records will get store MENU_ID,ENTRY_SEQUENCE,LANGUAGE wise.
    Could any one please suggest me how to resolve this problem.
    Thanks,
    Praba TPl do not abuse the forums by cross-posting in multiple forums
    Sorting Problem in FND_MENU_ENTRIES_TL Table
    Sorting Problem in FND_MENU_ENTRIES_TL Table
    Your issue is related to EBS, not to database upgrades (which is the topic of this forum)
    Srini

  • Sorting problems in Grid View

    Hi, I'm having a bit of a sorting problem when it comes to an artist with name variations. The example I'm going to use is DJ Tiesto.
    There are album I have where he is credited as DJ Tiesto, and others where he is simply Tiesto.
    In the end, I'd like these albums sorted chronologically under one name (say DJ Tiesto), while still preserving and showing the proper artist name for each album. I have it set to sort by "Album by Year", which is working fine.
    The major problem I am having is that I can't get it to display properly across all iTunes viewing methods: List mode, Grid mode, and Coverflow.
    I've tried leaving the Artist field alone, and changing the Sort Artist field to "DJ Tiesto" for all songs, and that almost works:
    -List mode groups them all under "DJ Tiesto", while showing each albums Artist as the correct artist name.
    -Grid mode sorted by Album groups them all under "DJ Tiesto", while showing each albums Artist as the correct artist name.
    -Coverflow sorts them all in chronological order, while showing each albums Artist as the correct artist name.
    Problem is, Grid mode sorted by ARTIST creates two separate artists! Some for DJ Tiesto and some for Tiesto!
    To correct this I tried changing the Album Artist field for all songs to "DJ Tiesto", which solved that problem but created a bunch of new ones:
    -List mode is still correctly grouping them under "DJ Tiesto", while showing each albums Artist as the correct artist name.
    -Grid mode sorted by Album is still correctly grouping them under "DJ Tiesto", *however now it is not displaying the correct Artist name for each album!*
    -Grid mode sorted by Artist is now grouping them all under "DJ Tiesto", *however it is not displaying the correct Artist name for each album!*
    -Coverflow is sorting them in correct chronological order, *however it as well is not displaying the correct Artist name for each album!*
    Using the Album Artist tag has created more problems that it has solved! Is there anyone who knows a way to achieve what I am trying to do? I have tried seemingly every option I can and have still not found a way to do this!!
    Thanks!

    My own method of working involves renaming the files upon import to:
    i "shotdate_sequencenumber"
    Files are therefore typically named
    b 2007-11-25_001
    etc.
    This way, sorting by Filename automatically sorts by Date by default. And it wouldn't even matter if you added a descriptive text in between the date and number (
    b 2007-11-25_Scotland_001

  • Sorting problem in standard vendor search help

    Hi all,
    I'm enhancing the vendor search help.
    I found that there is a sorting problem in the original standard search help.
    The 1st time to search vendor in the search help returns a correct list, then I just sort the vendor in ascending order. This time the column name of the hit list changes and mismatch the actual values.
    Any one faced this problem before?
    What's wrong are there ?
    Thanks.

    Thanks Peluka.
    But even I don't enhance the vendor search help, I still found that the original standard version has this problem after sorting.
    Is that the program bug?
    Have anyone encountered this problem before?

  • Datagrid vertical scrollbar problem

    I wrote a search function for a datagrid component. The
    dataprovider is a ArrayCollection variable. If the item is found in
    the array, set the item to be selected in the datagrid. The problem
    is when the selected item is at bottom of the datagrid, the
    scrollbar doesn't refresh so I have to manually move the scrollbar
    to see the selected item. Here is part of my code:
    <mx:Script>
    <![CDATA[
    ......(populate accountData using dataservice)
    accountDS.fill(accountData);
    private function findAccountById(id:String):void
    var size:int = accountData.length - 1;
    for(var i:int = 0; i< size; i++) {
    var account:Object = accountData.getItemAt(i);
    if(account.accountNumber.search(id) != -1)
    dgAccount.selectedIndex = i;
    break;
    ]]>
    </mx:Script>
    <mx:ArrayCollection id="accountData"/>
    <mx:DataService id="accountDS"
    destination="accountlist"/>
    <mx:Panel >
    <mx:DataGrid id="dgAccounts" dataProvider="{accountData}"
    editable="false">
    <mx:columns>
    <mx:DataGridColumn dataField="accountNumber"/>
    <mx:DataGridColumn dataField="accountType" />
    </mx:columns>
    </mx:DataGrid>
    </mx:Panel>

    You need to look at the API for DataGrid. Particularly the
    property "verticalScrollPosition".
    The logic in your expectation that setting selectedIndex
    should update the scroll position is flawed. What if you selected
    an item with the mouse and then wanted to browse the other options?
    You would use the scroll bar for this. Your selection might
    disappear from the list but you would want it to stay selected.
    Thus the scroll position and the selected index are completely
    independent of one another.
    The point I am trying to make is this: you are required to
    set the verticalScrollPosition when you set selectedIndex if you
    want them to work in concert.

  • DataGrid Sorting Problem

    Hi all,
    We are running one query from Sql Query Analyser ,
    for selecting values and displaying it in ascending order.
    We are executing the same query from coding to load in to
    datagrid , but its not arranging it by ascending order instead
    its sorting randomly.
    Because of this, if i select particular row from Datagrid, its not fetching
    the selected row from the grid instead its taking corresponding row number's
    value.
    Thanks
    Vaithy

    HI  vaitheeswaran l...    ,
    yeah what u said is correct grid takes in that manner when u are using collapse levels.try without using collapse levels.if u want using collapse levels it wont come
    Edited by: micheal willis on Oct 9, 2009 11:34 AM

  • LineChart category axis labelFunction / dataProvider problem

    Hi,
    I am trying to plot a line chart using actionscript.
    What I am trying to achive is plot the chart with entire dataset, but show only limited number of points in x and y axis's.
    Problem:
         When I give dataProvider to category axis with some limited values, nothing gets plotted .
    Explaination:
         In the attached main.mxml file
                    var lineCategoryXAxis:CategoryAxis = new CategoryAxis();
                    //lineCategoryXAxis.dataProvider = getDatePointsArray(datesArray);
                    lineCategoryXAxis.categoryField = "DATE";
                    lineCategoryXAxis.labelFunction = lineCategoryXAxisLabelFunction;
                    lineChart.horizontalAxis = lineCategoryXAxis;
    Here, I am giving category axis for x-axis. Linechart takes care of values in the vertical axis by itself and so the line chart gets plotted properly.
    But when I try giving values to vertical axis, then nothing is plotted in the line chart.
                    var lineCategoryYAxis:CategoryAxis = new CategoryAxis();
                     lineCategoryYAxis.dataProvider = getNumericPointsArray(valuesArray)
                     //lineCategoryYAxis.categoryField = "VALUE";
                     lineCategoryYAxis.labelFunction = lineCategoryYAxisLabelFunction;
                     lineChart.verticalAxis = lineCategoryYAxis;
    Also if I try to reduce the number of points in the x-axis, nothing gets plotted
                   var lineCategoryXAxis:CategoryAxis = new CategoryAxis();
                     lineCategoryXAxis.dataProvider = getDatePointsArray(datesArray);
                     lineCategoryXAxis.labelFunction = lineCategoryXAxisLabelFunction;
                     lineChart.horizontalAxis = lineCategoryXAxis;
    where getNumericPointsArray() returns an array with 7 values for vertical axis and getDatePointsArray() returns array with 7 dates for horizontal axis.
    Need help in resolving this problem.
    P.S: Unable to attach mxml file so attaching it as a txt file.

    Hi,
    This is the code:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        xmlns:components="com.yahoo.data.digits.components.*"
        layout="vertical"
        backgroundColor="#FFFFFF"
        backgroundGradientAlphas="[0,0]"
        width="100%" creationComplete="cc()">
        <mx:Script>
            <![CDATA[
                import mx.utils.ArrayUtil;
                import mx.collections.XMLListCollection;
                import mx.collections.Sort;
                import mx.charts.CategoryAxis;
                import mx.charts.chartClasses.Series;
                import mx.collections.ArrayCollection;
                import mx.charts.series.LineSeries;
                import mx.charts.LineChart;
                public var dataForLineChart:ArrayCollection = new ArrayCollection([
                                                                {DATE:"20090509", VALUE:"3538943147"},
                                                                {DATE:"20090510", VALUE:"5047760823"},
                                                                {DATE:"20090511", VALUE:"5046865494"},
                                                                {DATE:"20090512", VALUE:"4983771032"},
                                                                {DATE:"20090513", VALUE:"5032039834"},
                                                                {DATE:"20090514", VALUE:"4897303525"},
                                                                {DATE:"20090515", VALUE:"4496020991"},
                                                                {DATE:"20090516", VALUE:"3525547244"},
                                                                {DATE:"20090517", VALUE:"3596982398"},
                                                                {DATE:"20090518", VALUE:"4947978254"},
                                                                {DATE:"20090519", VALUE:"4932182219"},
                                                                {DATE:"20090520", VALUE:"4909069875"},
                                                                {DATE:"20090521", VALUE:"4781830807"},
                                                                {DATE:"20090522", VALUE:"4431176690"},
                                                                {DATE:"20090523", VALUE:"3476323135"},
                                                                {DATE:"20090524", VALUE:"3444512240"},
                                                                {DATE:"20090525", VALUE:"4329018809"},
                                                                {DATE:"20090526", VALUE:"5086390081"},
                                                                {DATE:"20090527", VALUE:"5012778551"},
                                                                {DATE:"20090528", VALUE:"4770167180"},
                                                                {DATE:"20090529", VALUE:"4408927585"},
                                                                {DATE:"20090531", VALUE:"3488537357"},
                                                                {DATE:"20090601", VALUE:"3630748728"},
                                                                {DATE:"20090602", VALUE:"5007093913"},
                                                                {DATE:"20090603", VALUE:"5015210737"},
                                                                {DATE:"20090604", VALUE:"4999236097"},
                                                                {DATE:"20090605", VALUE:"4934609881"},
                                                                {DATE:"20090606", VALUE:"4588135281"},
                                                                {DATE:"20090607", VALUE:"3615291868"},
                                                                {DATE:"20090608", VALUE:"3666209346"},
                private function cc():void
                    var lineSeriesArray:Array = new Array();
                    var lineChart:LineChart = new LineChart();
                    lineChart.percentHeight = 100;
                    lineChart.percentWidth = 100;
                    lineChart.showDataTips = true;
                    lineChart.dataProvider = dataForLineChart;
                    var valuesArray:Array = new Array();
                    var datesArray:Array = new Array();
                    var lineSeries:LineSeries;
                    lineSeries = new LineSeries();
                    lineSeries.dataProvider = dataForLineChart;
                    lineSeries.dataFunction = lineSeriesDataFunction;
                    lineSeriesArray.push(lineSeries);
                    var dLength:int = dataForLineChart.length;
                    for (var k:int=0;k<dLength;k++)
                        valuesArray.push(dataForLineChart[k].VALUE);
                        datesArray.push(dataForLineChart[k].DATE);
                    lineChart.series = lineSeriesArray;
                    var lineCategoryXAxis:CategoryAxis = new CategoryAxis();
                    //lineCategoryXAxis.dataProvider = getDatePointsArray(datesArray);
                    lineCategoryXAxis.categoryField = "DATE";
                    lineCategoryXAxis.labelFunction = lineCategoryXAxisLabelFunction;
                    lineChart.horizontalAxis = lineCategoryXAxis;
                    var lineCategoryYAxis:CategoryAxis = new CategoryAxis();
                    //lineCategoryYAxis.dataProvider = getNumericPointsArray(valuesArray)
                    lineCategoryYAxis.categoryField = "VALUE";
                    lineCategoryYAxis.labelFunction = lineCategoryYAxisLabelFunction;
                    //lineChart.verticalAxis = lineCategoryYAxis;
                    chartContainer.removeAllChildren();
                    chartContainer.addChild(lineChart);
                private function lineCategoryXAxisLabelFunction(categoryValue:Object, previousCategoryValue:Object, axis:CategoryAxis, categoryItem:Object):String
                    /** Will do date formatting here */
                    return categoryItem.DATE;
                    //return categoryItem.toString();
                private function lineCategoryYAxisDataFunction(axis:CategoryAxis, item:Object):Object
                    return item.VALUE;
                private function lineCategoryYAxisLabelFunction(categoryValue:Object, previousCategoryValue:Object, axis:CategoryAxis, categoryItem:Object):String
                    /** Will do number formatting here */
                    return categoryItem.VALUE;
                    //return categoryItem.toString();
                private function lineSeriesDataFunction(series:Series, item:Object, fieldName:String):Object
                    if (fieldName == "yValue")
                        return item.VALUE;
                    else if(fieldName == "xValue")
                        return item.DATE.toString();
                    return null;
                private function getNumericPointsArray(inputArray:Array):Array
                    var numValues:int = inputArray.length;
                    /** Sorting the array to find min and max values */
                    var inputAC:ArrayCollection = new ArrayCollection(inputArray);
                    inputAC.sort = new Sort();
                    inputAC.refresh();
                    var minValue:Number = Number(inputAC.getItemAt(0));
                    var maxValue:Number = Number(inputAC.getItemAt(inputAC.length - 1));
                    var outputArray:Array = new Array();
                    var i:int;
                    var diffFactor:Number;
                    var diffMinMax:Number;
                    /** axis takes 0 by default so not pushing that into array */       
                    if (minValue == maxValue)
                        /** Dividing by 6 to get 5 points */
                        diffFactor = Math.round(maxValue / 6);
                        for (i=1;i<=5;i++)
                            outputArray.push((i * diffFactor));
                        outputArray.push(maxValue);
                    else
                        outputArray.push(minValue);
                        /** Find some points between minValue and maxValue */
                        diffMinMax = (maxValue - minValue);
                        /** Dividing by 5 to get 4 points */
                        diffFactor = Math.round(diffMinMax / 5);
                        for (i=1;i<=4;i++)
                            outputArray.push((i * diffFactor) + minValue);
                        outputArray.push(maxValue);
                    return outputArray;
                private function getDatePointsArray(inputArray:Array):Array
                    var numValues:int = inputArray.length;
                    /** Subtracting 2 because first and last values are undconditinally pushed in output array.*/
                    var stepValue:int = (numValues - 2) / 5;
                    var outputArray:Array = new Array();
                    outputArray.push(inputArray[0]);
                    /** Starting from 1 and ending in numValues - 2 because first and last values of array are already taken.*/
                    for (var i:int=stepValue;i<numValues - 2;i+=stepValue)
                        outputArray.push(inputArray[i]);
                    outputArray.push(inputArray[numValues - 1]);
                    return outputArray;
            ]]>
        </mx:Script>
        <mx:HBox id="chartContainer" width="100%" height="100%">
        </mx:HBox>
    </mx:Application>
    As you can see in the code, my dataPovider is complex (can become much more complex). In the code above, the ArrayCollection has only one element currently but will have more. So the graph should be plotted in such a way that each array element corresponds to one line series.
    What I need to achive is that the horizontal axis should show dates only from the "0th" element of the ArrayCollection and that too only some limited 6-7 points, the rest of the ArrayCollection elements should get plotted according to these dates.
    I think I was able to explain my problem. Pls let me know if any more explaination is required.
    P.S. Re-attaching the file.
    Thanks in advance

  • DataGrid scroll bar problem

    Hi all,
    My datagrid is edit mode, only for edit without selectable.
    But when I click on the scroll bar, it would auto select the row in
    scrolling position. And the cell focus would auto stay in the
    selected row first column. Anyone has idea to solve it? Is the
    datagrid has some setting need to be changed?
    Thanks

    I don't know if I understand the problem correctly.
    If you want the data to be sorted only on startup you should disable sorting (sortableColumns = false) and sort it manually upon initialization. Then, when you change a value of a combobox in a row, no sorting will occur.
    Does this help?
    Dany

  • DataGrid Header shadow Problem.

    Hello,
    Here is my problem: I have this DataGrid with all kind of
    custom styles, backgroud colors, cell colors, fonts. etc. I can't
    figure out how to get rid of the black line right under the header.
    It's like a 1px stroke solid black........Am I on Crack, is this
    even possible? I know you can hide the header, but I want to keep
    it for sorting purposes. Thanks for any help.

    I think the column still exists even if you set its visibility to false. You could try something like this
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:local="*">
        <mx:Script>
        <![CDATA[
            import mx.controls.listClasses.BaseListData;
            import mx.controls.dataGridClasses.DataGridListData;
            import mx.controls.dataGridClasses.DataGridItemRenderer;
            import mx.events.ListEvent;
            import mx.controls.*;
            private function grd_click(e:ListEvent):void{
                    var icol:int = e.columnIndex;
                    var column:DataGridColumn = DataGridColumn(grid1.columns[icol]);
                    var headerTxt:String = column.headerText;
                    Alert.show("Header text = " + headerTxt)
            private function hideCol(index:int):void{
              if(index == 0)
                  grid1.columns = [column1];
              else
                  grid1.columns = [column2];
            [Bindable]private var items:Array = [
                {name:"vlad",lname:"collak"},
        ]]>
    </mx:Script>
        <mx:DataGrid x="90" y="99" itemClick="grd_click(event)" id="grid1" dataProvider="{items}">
            <mx:columns>
                <mx:DataGridColumn id="column1" headerText="Column 1" dataField="name" />
                <mx:DataGridColumn id="column2" headerText="Column 2" dataField="lname"/>         
            </mx:columns>
        </mx:DataGrid>
        <mx:Button x="90" y="262" label="Hide Column" click="hideCol(0)"/>
        <mx:Label x="90" y="56" text="Click on column content and the code will show col # and header name. Do the same After Hide Colun  is clicked" width="642" height="35"/>
    </mx:Application>

  • Sort problem in a report

    Hi,
    I'm using the sort on a report with 7 columns. For each column I've specified
    the sort sequence from 1 to 7. The last sort is a date field. If i sort now the
    last column and i change to next report side the sort change jump to the first column.
    Is there somebody who had also a problem like this?
    Greets,
    Tom

    You can check boxes to determine which columns can be sorted; if you check one or more boxes, you also need to set the "Sort Sequence" attribute under the "Report Attributes" tab of your SQL query region. So to use sorting you must.
    1. ensure you don't have an order by in your SQL statement
    2. check one or more "sort" boxes
    3. set the default order in one or more column in the "sort sequence" column
    Hope this helps,
    Mike

  • Sorting Problem in XML Publisher Report

    Dear Members,
    I am facing problems with sorting data in my XML Publisher Report.
    We are using Oracle E-Business Suite 12.1 Version and i developed a rtf Template and executable is an RDF which generates XML Data.
    I want the whole report to group by element ITEM_NAME which is a character in the ascending order. I tried several ways but it is not working properly.
    I don't know how to upload the RTF template in this forum. I tried to post the XML Code and since its excceds 30000 characters i cant post it in the forum.
    Any help is greatly appreciated.
    Thanks
    Sandeep

    You can't upload the template here; you can post a part of the relevant XML code and template code here.
    or send me a sample XML and RTF template to [email protected] and I will take a look.

  • Mail sorting problem after upgrading to Mountain Lion?

    I have a strange problem with Mail after upgrading to Mountain Lion.
    Before upgrading, when I tried to search my Mail Inbox for e-mails from a specific sender, the esearch results would be indexed by the name of the sender. For example: when I entered 'John Smith' in the search box in Mail, it would display a list of email from 'John Smith'
    Now after upgrading, the same query indexes the search results by the 'To' address i.e. my email address.For example: if my name is 'Steve Johnson', a search for 'John Smith' in the search box in Mail displays a list of email to 'Steve Johnson' and not from 'John Smith' which is how it used to display before.
    My emails are sorted by Date always, and I am using the default Mail view [not classic view]
    Can someone please help with a fix for this to help me get back to the original display I had while searching? Thanks in advance.

    I'm having the same problem.  It's incredibly annoying!!!  Did you find an answer?

  • Help with Artist Sort Problem Needed...

    This is a bit long, so I'll start with the three main questions and below them is the backstory and detail of the problem (I did do a search but nothing turned up):
    1) Does anyone know how to fix artist sorting issues where the artists are properly sorted (alphabetically by last name and band name) but there are constant grey-bar letter headings for the first name (sorry...I don't know how to explain better than I do below in detail)
    2) Will re-setting the Touch require I have to...
    a) re-add all the songs I've manually selected again
    b) re-input any data saved to apps (such as CarCare and
    Pocketpedia) and if so, can I backup that data first?
    3) If all the re-doing in 2 above is necessary if I were to re-set the iPod, can anyone think of an alternative fix that would avoid a reset?
    I might be able to get to an Apple store this weekend to ask a "genius" but I'm not that confident in them since I was given some incorrect information on how the Touch handles playlists at the time of original purchase.
    Okay... now, what happened:
    I'm not sure what to make of this, fortunately playback and all main functions are unaffected. I have my iPod Touch 2g set for manual sync. Today, while I was charging it at work, my PC (WinXP) froze. I gave it plenty of time to unfreeze, but eventually had no choice but to do a hard reboot while the iPod said "syncing." I slid the slider to cancel the sync, but the iPod didn't respond. I unhooked it from the PC and it unfroze. I shut it down and re-started.
    Everything seemed fine after the iPod reboot except that now, while the artists are still sorted alphabetically (I've manually set artists to sort by last name), there are headers using the first letter of the first name between each artist. So, for instance, this is how the top of my artist list looks now (lines below with just a letter are the grey divider bar with the alphabetical header):
    R
    Ryan Adams
    D
    Dave Alvin
    T
    Tori Amos
    E
    Eric Andersen
    A
    Apples in Stereo
    Arcade Fire
    L
    Louis Armstrong
    A
    Ataris
    ...etc.
    This problem has not extended to album or song title fields, but for some reason, when scrolling through the album view using the index on the right, it moves fine until "O" -- then it sits still as I scroll down until it gets to "#", at which point it's resposnive again.
    I've checked the music library on the iPod via iTunes and the artist sort fields are still correct.
    Suggestions? I'm new to the Touch and am leery of doing a reset yet since it's taken time to figure out which songs from my 100+gb library to manually put on this. Also, I have no idea how it will affect the apps I've downloaded. There are some where I've saved data (such as CarCare and Pocketpedia) and I REALLY don't want to risk having to re-input all that data.
    To anyone with any words of advice, thanks in advance.
    Message was edited by: IronWaffle
    Message was edited by: IronWaffle

    This is an answer to only qestion 2. Yes restoring your ipod will delete all songs, apps, videos, etc., but you can back up settings like a passcode lock or screen brightness. But it will ask if you want to back up settings. If your'e on windows, in itunes go to file and down almost all the way you will see a "Tranfer purchases from (ex.) steves ipod" and that will make sure you have all your apps and music and other stuff.

  • JTable sorting - problem when adding elements (complete code inside)

    I�m writing this email with reference to a recent posting here but this time with the code example. (I apologize for the duplicated posting � this time it will be with the code)
    Problem: when adding more elements to the JTable (sorted) the exception: ArrayIndexOutOfBoundsException is thrown.
    Example: If the elements in the table are 10 and then the user requests for 8 � the table will produce the correct result. However, if the user will ask for 11 items (>10) the exception will be thrown.
    The program: The program below (compiles and running). A JTable is constructed with 3 items, when you click the button - the return result should be 4 items - this will generate the error, WHY?
    I would highly appreciate your thoughts why this is happening and most importantly � how to fix it.
    Thanks a lot
    3 files:
    (1) TableSorterDemo
    (2) Traveler
    (3)TableSorter
    //TableSorterDemo:
    package sorter;
    import javax.swing.DefaultListModel;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.table.AbstractTableModel;
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    * TableSorterDemo is like TableDemo, except that it
    * inserts a custom model -- a sorter -- between the table
    * and its data model.  It also has column tool tips.
    public class TableSorterDemo implements ActionListener
         private JPanel superPanel;
         private JButton clickMe = new JButton("click me to get diff data");
         private boolean DEBUG = false;
         private DefaultListModel defaultListModel;
         private JTable table;
        public TableSorterDemo()
             superPanel = new JPanel(new BorderLayout());
             defaultListModel = new DefaultListModel();
             init1();
            TableSorter sorter = new TableSorter(new MyTableModel(defaultListModel)); //ADDED THIS     
            table = new JTable(sorter);             //NEW
            sorter.setTableHeader(table.getTableHeader()); //ADDED THIS
            table.setPreferredScrollableViewportSize(new Dimension(500, 70));
            //Set up tool tips for column headers.
            table.getTableHeader().setToolTipText(
                    "Click to specify sorting; Control-Click to specify secondary sorting");
            //Create the scroll pane and add the table to it.
            JScrollPane scrollPane = new JScrollPane(table);
            //Add the scroll pane to this panel.
            superPanel.add("Center", scrollPane);
            superPanel.add("South",clickMe);
            clickMe.addActionListener(this);              
        public JPanel getPanel()
             return superPanel;
        public void init1()
             //in real life this will be done from the db
             Traveler a = new Traveler();
             Traveler b = new Traveler();
             Traveler c = new Traveler();
             a.setFirstName("Elvis");
             a.setLastName("Presley");
             a.setSprot("Ping Pong");
             a.setNumYears(3);
             a.setVegetarian(true);
             b.setFirstName("Elton");
             b.setLastName("John");
             b.setSprot("Soccer");
             b.setNumYears(2);
             b.setVegetarian(true);
             c.setFirstName("shaquille");
             c.setLastName("oneil");
             c.setSprot("Golf");
             c.setNumYears(22);
             c.setVegetarian(true);
             defaultListModel.addElement(a);
             defaultListModel.addElement(b);
             defaultListModel.addElement(c);
        public void init2()
             //in real life this will be done from the db
             Traveler d = new Traveler();
             Traveler e = new Traveler();
             Traveler f = new Traveler();
             Traveler g = new Traveler();
             d.setFirstName("John");
             d.setLastName("Smith");
             d.setSprot("Tennis");
             d.setNumYears(32);
             d.setVegetarian(true);
             e.setFirstName("Ron");
             e.setLastName("Cohen");
             e.setSprot("Baseball");
             e.setNumYears(12);
             e.setVegetarian(true);
             f.setFirstName("Donald");
             f.setLastName("Mac Novice");
             f.setSprot("Vallyball");
             f.setNumYears(1);
             f.setVegetarian(true);
             g.setFirstName("Eithan");
             g.setLastName("Superstar");
             g.setSprot("Vallyball");
             g.setNumYears(21);
             g.setVegetarian(true);
             defaultListModel.addElement(d);
             defaultListModel.addElement(e);
             defaultListModel.addElement(f);
             defaultListModel.addElement(g);            
        class MyTableModel extends AbstractTableModel
             private DefaultListModel myModel;
             public MyTableModel(DefaultListModel m)
                  myModel=m;
            private String[] columnNames = {"First Name",
                                            "Last Name",
                                            "Sport",
                                            "# of Years",
                                            "Vegetarian"};
            public int getColumnCount()
                return columnNames.length;
            public int getRowCount()
                return myModel.size();
            public String getColumnName(int column)
                 return getNames()[column];             
             public String[] getNames()
                  String[] names = {"First Name", "Last Name", "Sport", "# of Years", "Vegetarian"};
                  return names;
            public Object getValueAt(int row, int col)
                 return distributeObjectsInTable(row, col, (Traveler) myModel.elementAt(row));
            public Object distributeObjectsInTable(int row, int col, Traveler tr)
               switch(col)
                         case 0:
                              return tr.getFirstName();
                         case 1:
                           return tr.getLastName();
                      case 2:
                           return tr.getSprot();
                      case 3:
                           return new Integer(tr.getNumYears());
                      case 4:
                           return new Boolean (tr.isVegetarian());
                     default:
                         return "Error";
            public Class getColumnClass(int c)
                return getValueAt(0, c).getClass();
        private static void createAndShowGUI()
            //Make sure we have nice window decorations.
            JFrame.setDefaultLookAndFeelDecorated(true);
            //Create and set up the window.
            JFrame frame = new JFrame("TableSorterDemo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Create and set up the content pane.
            TableSorterDemo newContentPane = new TableSorterDemo();
            newContentPane.getPanel().setOpaque(true); //content panes must be opaque
            frame.setContentPane(newContentPane.getPanel());
            //Display the window.
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args)
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable()                   
                public void run()
                    createAndShowGUI();
         public void actionPerformed(ActionEvent ae)
              if (ae.getSource()==clickMe)
                   defaultListModel.removeAllElements();
                   init2(); //if the size of the model was less than 2 items - the result will be ok.
                              //in other words, if you commens the last 2 rows of this method (addElement(f) & g)
                             // the result will be fine.
                   table.updateUI();          
    }//(2) Traveler
    package sorter;
    public class Traveler
         private String firstName;
         private String lastName;
         private String sprot;
         private int numYears;
         private boolean vegetarian;
         public String getFirstName()
              return firstName;
         public String getLastName()
              return lastName;
         public int getNumYears()
              return numYears;
         public String getSprot()
              return sprot;
         public boolean isVegetarian()
              return vegetarian;
         public void setFirstName(String firstName)
              this.firstName = firstName;
         public void setLastName(String lastName)
              this.lastName = lastName;
         public void setNumYears(int numYears)
              this.numYears = numYears;
         public void setSprot(String sprot)
              this.sprot = sprot;
         public void setVegetarian(boolean vegetarian)
              this.vegetarian = vegetarian;
    }//(3)TableSorter
    package sorter;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.util.List;
    import javax.swing.*;
    import javax.swing.event.TableModelEvent;
    import javax.swing.event.TableModelListener;
    import javax.swing.table.*;
    public class TableSorter extends AbstractTableModel {
        protected TableModel tableModel;
        public static final int DESCENDING = -1;
        public static final int NOT_SORTED = 0;
        public static final int ASCENDING = 1;
        private static Directive EMPTY_DIRECTIVE = new Directive(-1, NOT_SORTED);
        public static final Comparator COMPARABLE_COMAPRATOR = new Comparator() {
            public int compare(Object o1, Object o2) {
                return ((Comparable) o1).compareTo(o2);
        public static final Comparator LEXICAL_COMPARATOR = new Comparator() {
            public int compare(Object o1, Object o2) {
                return o1.toString().compareTo(o2.toString());
        private Row[] viewToModel;
        private int[] modelToView;
        private JTableHeader tableHeader;
        private MouseListener mouseListener;
        private TableModelListener tableModelListener;
        private Map columnComparators = new HashMap();
        private List sortingColumns = new ArrayList();
        public TableSorter() {
            this.mouseListener = new MouseHandler();
            this.tableModelListener = new TableModelHandler();
        public TableSorter(TableModel tableModel) {
            this();
            setTableModel(tableModel);
        public TableSorter(TableModel tableModel, JTableHeader tableHeader) {
            this();
            setTableHeader(tableHeader);
            setTableModel(tableModel);
        private void clearSortingState() {
            viewToModel = null;
            modelToView = null;
        public TableModel getTableModel() {
            return tableModel;
        public void setTableModel(TableModel tableModel) {
            if (this.tableModel != null) {
                this.tableModel.removeTableModelListener(tableModelListener);
            this.tableModel = tableModel;
            if (this.tableModel != null) {
                this.tableModel.addTableModelListener(tableModelListener);
            clearSortingState();
            fireTableStructureChanged();
        public JTableHeader getTableHeader() {
            return tableHeader;
        public void setTableHeader(JTableHeader tableHeader) {
            if (this.tableHeader != null) {
                this.tableHeader.removeMouseListener(mouseListener);
                TableCellRenderer defaultRenderer = this.tableHeader.getDefaultRenderer();
                if (defaultRenderer instanceof SortableHeaderRenderer) {
                    this.tableHeader.setDefaultRenderer(((SortableHeaderRenderer) defaultRenderer).tableCellRenderer);
            this.tableHeader = tableHeader;
            if (this.tableHeader != null) {
                this.tableHeader.addMouseListener(mouseListener);
                this.tableHeader.setDefaultRenderer(
                        new SortableHeaderRenderer(this.tableHeader.getDefaultRenderer()));
        public boolean isSorting() {
            return sortingColumns.size() != 0;
        private Directive getDirective(int column) {
            for (int i = 0; i < sortingColumns.size(); i++) {
                Directive directive = (Directive)sortingColumns.get(i);
                if (directive.column == column) {
                    return directive;
            return EMPTY_DIRECTIVE;
        public int getSortingStatus(int column) {
            return getDirective(column).direction;
        private void sortingStatusChanged() {
            clearSortingState();
            fireTableDataChanged();
            if (tableHeader != null) {
                tableHeader.repaint();
        public void setSortingStatus(int column, int status) {
            Directive directive = getDirective(column);
            if (directive != EMPTY_DIRECTIVE) {
                sortingColumns.remove(directive);
            if (status != NOT_SORTED) {
                sortingColumns.add(new Directive(column, status));
            sortingStatusChanged();
        protected Icon getHeaderRendererIcon(int column, int size) {
            Directive directive = getDirective(column);
            if (directive == EMPTY_DIRECTIVE) {
                return null;
            return new Arrow(directive.direction == DESCENDING, size, sortingColumns.indexOf(directive));
        private void cancelSorting() {
            sortingColumns.clear();
            sortingStatusChanged();
        public void setColumnComparator(Class type, Comparator comparator) {
            if (comparator == null) {
                columnComparators.remove(type);
            } else {
                columnComparators.put(type, comparator);
        protected Comparator getComparator(int column) {
            Class columnType = tableModel.getColumnClass(column);
            Comparator comparator = (Comparator) columnComparators.get(columnType);
            if (comparator != null) {
                return comparator;
            if (Comparable.class.isAssignableFrom(columnType)) {
                return COMPARABLE_COMAPRATOR;
            return LEXICAL_COMPARATOR;
        private Row[] getViewToModel() {
            if (viewToModel == null) {
                int tableModelRowCount = tableModel.getRowCount();
                viewToModel = new Row[tableModelRowCount];
                for (int row = 0; row < tableModelRowCount; row++) {
                    viewToModel[row] = new Row(row);
                if (isSorting()) {
                    Arrays.sort(viewToModel);
            return viewToModel;
        public int modelIndex(int viewIndex)
            return getViewToModel()[viewIndex].modelIndex;
        private int[] getModelToView()
            if (modelToView == null) {
                int n = getViewToModel().length;
                modelToView = new int[n];
                for (int i = 0; i < n; i++) {
                    modelToView[modelIndex(i)] = i;
            return modelToView;
        // TableModel interface methods
        public int getRowCount() {
            return (tableModel == null) ? 0 : tableModel.getRowCount();
        public int getColumnCount() {
            return (tableModel == null) ? 0 : tableModel.getColumnCount();
        public String getColumnName(int column) {
            return tableModel.getColumnName(column);
        public Class getColumnClass(int column) {
            return tableModel.getColumnClass(column);
        public boolean isCellEditable(int row, int column) {
            return tableModel.isCellEditable(modelIndex(row), column);
        public Object getValueAt(int row, int column) {
            return tableModel.getValueAt(modelIndex(row), column);
        public void setValueAt(Object aValue, int row, int column) {
            tableModel.setValueAt(aValue, modelIndex(row), column);
        // Helper classes
        private class Row implements Comparable {
            private int modelIndex;
            public Row(int index) {
                this.modelIndex = index;
            public int compareTo(Object o) {
                int row1 = modelIndex;
                int row2 = ((Row) o).modelIndex;
                for (Iterator it = sortingColumns.iterator(); it.hasNext();) {
                    Directive directive = (Directive) it.next();
                    int column = directive.column;
                    Object o1 = tableModel.getValueAt(row1, column);
                    Object o2 = tableModel.getValueAt(row2, column);
                    int comparison = 0;
                    // Define null less than everything, except null.
                    if (o1 == null && o2 == null) {
                        comparison = 0;
                    } else if (o1 == null) {
                        comparison = -1;
                    } else if (o2 == null) {
                        comparison = 1;
                    } else {
                        comparison = getComparator(column).compare(o1, o2);
                    if (comparison != 0) {
                        return directive.direction == DESCENDING ? -comparison : comparison;
                return 0;
        private class TableModelHandler implements TableModelListener {
            public void tableChanged(TableModelEvent e) {
                // If we're not sorting by anything, just pass the event along.            
                if (!isSorting()) {
                    clearSortingState();
                    fireTableChanged(e);
                    return;
                // If the table structure has changed, cancel the sorting; the            
                // sorting columns may have been either moved or deleted from            
                // the model.
                if (e.getFirstRow() == TableModelEvent.HEADER_ROW) {
                    cancelSorting();
                    fireTableChanged(e);
                    return;
                // We can map a cell event through to the view without widening            
                // when the following conditions apply:
                // a) all the changes are on one row (e.getFirstRow() == e.getLastRow()) and,
                // b) all the changes are in one column (column != TableModelEvent.ALL_COLUMNS) and,
                // c) we are not sorting on that column (getSortingStatus(column) == NOT_SORTED) and,
                // d) a reverse lookup will not trigger a sort (modelToView != null)
                // Note: INSERT and DELETE events fail this test as they have column == ALL_COLUMNS.
                // The last check, for (modelToView != null) is to see if modelToView
                // is already allocated. If we don't do this check; sorting can become
                // a performance bottleneck for applications where cells 
                // change rapidly in different parts of the table. If cells
                // change alternately in the sorting column and then outside of            
                // it this class can end up re-sorting on alternate cell updates -
                // which can be a performance problem for large tables. The last
                // clause avoids this problem.
                int column = e.getColumn();
                if (e.getFirstRow() == e.getLastRow()
                        && column != TableModelEvent.ALL_COLUMNS
                        && getSortingStatus(column) == NOT_SORTED
                        && modelToView != null) {
                    int viewIndex = getModelToView()[e.getFirstRow()];
                    fireTableChanged(new TableModelEvent(TableSorter.this,
                                                         viewIndex, viewIndex,
                                                         column, e.getType()));
                    return;
                // Something has happened to the data that may have invalidated the row order.
                clearSortingState();
                fireTableDataChanged();
                return;
        private class MouseHandler extends MouseAdapter {
            public void mouseClicked(MouseEvent e) {
                JTableHeader h = (JTableHeader) e.getSource();
                TableColumnModel columnModel = h.getColumnModel();
                int viewColumn = columnModel.getColumnIndexAtX(e.getX());
                int column = columnModel.getColumn(viewColumn).getModelIndex();
                if (column != -1) {
                    int status = getSortingStatus(column);
                    if (!e.isControlDown()) {
                        cancelSorting();
                    // Cycle the sorting states through {NOT_SORTED, ASCENDING, DESCENDING} or
                    // {NOT_SORTED, DESCENDING, ASCENDING} depending on whether shift is pressed.
                    status = status + (e.isShiftDown() ? -1 : 1);
                    status = (status + 4) % 3 - 1; // signed mod, returning {-1, 0, 1}
                    setSortingStatus(column, status);
        private static class Arrow implements Icon {
            private boolean descending;
            private int size;
            private int priority;
            public Arrow(boolean descending, int size, int priority) {
                this.descending = descending;
                this.size = size;
                this.priority = priority;
            public void paintIcon(Component c, Graphics g, int x, int y) {
                Color color = c == null ? Color.GRAY : c.getBackground();            
                // In a compound sort, make each succesive triangle 20%
                // smaller than the previous one.
                int dx = (int)(size/2*Math.pow(0.8, priority));
                int dy = descending ? dx : -dx;
                // Align icon (roughly) with font baseline.
                y = y + 5*size/6 + (descending ? -dy : 0);
                int shift = descending ? 1 : -1;
                g.translate(x, y);
                // Right diagonal.
                g.setColor(color.darker());
                g.drawLine(dx / 2, dy, 0, 0);
                g.drawLine(dx / 2, dy + shift, 0, shift);
                // Left diagonal.
                g.setColor(color.brighter());
                g.drawLine(dx / 2, dy, dx, 0);
                g.drawLine(dx / 2, dy + shift, dx, shift);
                // Horizontal line.
                if (descending) {
                    g.setColor(color.darker().darker());
                } else {
                    g.setColor(color.brighter().brighter());
                g.drawLine(dx, 0, 0, 0);
                g.setColor(color);
                g.translate(-x, -y);
            public int getIconWidth() {
                return size;
            public int getIconHeight() {
                return size;
        private class SortableHeaderRenderer implements TableCellRenderer {
            private TableCellRenderer tableCellRenderer;
            public SortableHeaderRenderer(TableCellRenderer tableCellRenderer) {
                this.tableCellRenderer = tableCellRenderer;
            public Component getTableCellRendererComponent(JTable table,
                                                           Object value,
                                                           boolean isSelected,
                                                           boolean hasFocus,
                                                           int row,
                                                           int column) {
                Component c = tableCellRenderer.getTableCellRendererComponent(table,
                        value, isSelected, hasFocus, row, column);
                if (c instanceof JLabel) {
                    JLabel l = (JLabel) c;
                    l.setHorizontalTextPosition(JLabel.LEFT);
                    int modelColumn = table.convertColumnIndexToModel(column);
                    l.setIcon(getHeaderRendererIcon(modelColumn, l.getFont().getSize()));
                return c;
        private static class Directive {
            private int column;
            private int direction;
            public Directive(int column, int direction) {
                this.column = column;
                this.direction = direction;
    }

    The table listens to the TableModel for changes. Changing the table by adding/removing
    rows or columns has no affect on its table model. If you make changes to the table model
    the table will be notified by its TableModelListener and change its view. So tell
    MyTableModel about the change of data:
    public class TableSorterDemo implements ActionListener
        MyTableModel tableModel;
        public TableSorterDemo()
            defaultListModel = new DefaultListModel();
            init1();
            tableModel = new MyTableModel(defaultListModel);
            TableSorter sorter = new TableSorter(tableModel);
        public void actionPerformed(ActionEvent ae)
            if (ae.getSource()==clickMe)
                defaultListModel.removeAllElements();
                init2();
                tableModel.fireTableStructureChanged();
    }

  • Report Column Sorting problem

    I have a report based on a view. For some reason some of the columns are not being sorted correctly. After pressing the column header to sort date columns the underlying data is not sorted properly (it’s out of order) or it’s not sorted at all.
    Can you please let me know if there is a known bug causing that?

    I think I'm having the same problem.
    I have a report with data columns, several "not shown" columns, and several column links. I've noticed that any columns in the query after a certain point, will not sort the correct column. If I show all the columns and allow them all to sort, then some of the columns will sort the data in another column. (for example clicking on the header/sort link for column x sorts the table by column y and clicking on the sort link for column z sorts column x, etc).
    I've noticed that I can move columns around in my select query and no matter how they are arranged, after the 7th or 8th column in the select statement, none of the columns following that will sort properly. I've tried all kinds of things, changing my select query around, enabling and disabling sorting, adding additional null columns in, setting and unsetting the default sort order, changing the order of the columns in the report. I don't have an order by in my query or anything weird besides some where clauses (most of which are from the default search functionality).
    Has anyone found a solution to this problem? We just upgraded from HTML DB 2.2 to APEX 3.0 and the problem remained the same.
    Thanks,
    Greg

Maybe you are looking for

  • Profit Center wise ROI report considering BS items

    Dear Expert, As part of our SAP implementation 1.client wants , Profit center wise reporting for balance sheet items, for calculating ROI per profit center, can it be done? If yes, what balance sheet items , SAP standard willl consider while generati

  • DidReceiveRemoteNotification or didFinishLaunchingWithOptions do not get called in background

    I am using iOS 8.1 . I am sending the following APN {"aps":{"alert":{"body":"Hello sir","action-loc-key":"Caption of the second Button"},"badge":1,"sound":"default","content-available":1},"Key1":"Value1","Ke y2":"Value2"} As you see I am setting "con

  • Sound problems during transitions?

    Ok, i'm attempting to add a transition between a clip of some Talent Show MCs talking(I'm trying to cut out while they are saying something) right to a person singing, in then middle of a song. The sound is giving me issues, as the MCs keep talking w

  • Not supporting certain CSS properties

    One one of my windows XP systems firefox 10.0 does NOT render certain CSS properties. Specifically, at www.wbrogden.com the headlines should be in blue. In other tests background images are not rendered but text margins are correct. Firebug shows tha

  • SCCM client status show NO

    Hi All, i have deleted obsolete machine from SMS collection ‎‎after that i reinstalled the SMS client and readded the same machine ‎‎still that machine is showing client status is NO Please help me what to do