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)

Similar Messages

  • 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

  • WAD - how to design custom sorting of data?

    Hi,
    I have an analysis web item which is mapped to a query i.e a single data provider DP1.
    I have a requirement of disabling the pop up menu that appears on column right click of the report. I have done so. However, I require the sorting feature to be made available to the users. For this I have used a button & selected 'Set Sorting' command from under Characteristics. However, this lets me set sorting only for onw column & cannot be configured as toggle action.
    Plz. let me know how can I implement sorting feature on all columns of the report w/o having the pop-up menu OR if there is a way to have the pop-up menu only display sort option alone.
    Thanks.

    Hi,
    the af:column allows you to group columns
    <af:column>
    <af:column> </af:column>
    <af:column> </af:column>
    </af:clomn>
    Also, in HTML it is easy to assign a background color to cell, e.g. cell with Label 1 is red, Label 2 is green.
    Is there something like this in JSF?
    You can use CSS on the inlineStyl or contentStyle property to dynamically set CSS using EL. You can reference e.g. a managed bean , access the #{row} variable within the managed bean method and return the color based on the value you read for the each row
    Frank

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

  • 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

  • Customizing DataGrid component in Flash CS3 using AS3

    Can anyone please explain how to customize the DataGrid
    component in Flash CS3 using AS3???
    How do you remove/change the grid lines for the rows and
    colums?
    How do you remove/change the border?
    My day has been lost searching for this answer. Flash
    Documentation is worthless and Google finds nothing with regards to
    AS3. ASDGRH.
    Thanks in advance,
    TedWeb

    I hope you've found a resolution to this by now, but I just noticed the discussion title when posting a captioning issue.
    In a nutshell, create a listener on your FLVPlayback module with a VideoEvent.SKIN_LOADED event. You'll also need to set the showCaptions in your FLVPlaybackCaptioning object to true. Apparently, if the captions are set to false when the player object loads the skin, the captions aren't recognized and your captions toggle will require an extra click to activate the captions.
    Here's the link to another discussion on the same topic with all of the details:
    http://kb2.adobe.com/cps/402/kb402452.html
    Also, have you had any issues with the caption button in the FLVPlayback skin not showing up? That's my current issue. Here's the discussion for it:
    http://forums.adobe.com/thread/796423?tstart=0

  • No DataGrid component?

    I believe JavaFX seriously needs a DataGrid component to render tabular data as a GRID, where data can be paged, sorted, filtered like other data grid solutions (Adobe Flex, jQGrid, DataTables etc).
    This is one of the basic controls, any serious application would definitely need. TableView is the only closest thing I found, but that doesn't fit the bill at all.
    The DataFx project looks promising, but is very primitive.
    I hope Oracle will come up with a pretty GRID control soon, to beat the competition. We were planning to go with JavaFX and the only thing that is stopping us is the lack of a GRID component, we have to look for other web-based alternatives now.

    I think there's more to the TableView API than you're seeing, as it's supported by the JavaFX Properties and Collections APIs. The columns are exposed as a mutable, observable List, as is the data. So the columns are dynamic and can be readily changed as necessary, the table will update automatically.
    I used you example as a way to test this out; I've made no effort whatsoever to make this look good, the css is relatively straightforward. Also, I have no knowledge whatsoever of your business domain, so this will likely look somewhat naive. I think the code structure might be helpful though. There are some things I wish were a bit different but I'll come to that after the code.
    I'm going to assume you have some kind of data model and some way of knowing when the data's changed. I've mocked this up with a DataModel class with listener notification, but there are other ways this could happen (could be an EJB, for example). I've made this completely agnostic with respect to JavaFX.
    DataModel.java (a mockup of something I assume you already have existing):
    import java.util.ArrayList;
    import java.util.List;
    public class DataModel {
         private double minDeviation ;
         private double maxDeviation ;
         private int numDeviationCategories ;
         private int numRows ;
         private List<DataListener> listeners ;
         public DataModel(double minDeviation, double maxDeviation,
                   int numDeviationCategories, int numRows) {
              this.minDeviation = minDeviation;
              this.maxDeviation = maxDeviation;
              this.numDeviationCategories = numDeviationCategories;
              this.numRows = numRows;
              this.listeners = new ArrayList<DataListener>();
         public String getValue(int row, double deviation) {
              int category = (int) ((numDeviationCategories - 1)*(deviation - minDeviation) / (maxDeviation - minDeviation)) ;
              return String.format("f(%d, %d)", category+1, row+1);
         public double getMinDeviation() {
              return minDeviation;
         public void setMinDeviation(double minDeviation) {
              if (minDeviation != this.minDeviation) {
                   this.minDeviation = minDeviation;
                   fireDeviationRangeChanged();
         public double getMaxDeviation() {
              return maxDeviation;
         public void setMaxDeviation(double maxDeviation) {
              if (maxDeviation != this.maxDeviation) {
                   this.maxDeviation = maxDeviation;
                   fireDeviationRangeChanged();
         public int getNumDeviationCategories() {
              return numDeviationCategories;
         public void setNumDeviationCategories(int numDeviationCategories) {
              if (numDeviationCategories != this.numDeviationCategories) {
                   this.numDeviationCategories = numDeviationCategories;
                   fireNumDeviationCategoriesChanged();
         public int getNumRows() {
              return numRows;
         public void setNumRows(int numRows) {
              if (this.numRows != numRows) {
                   this.numRows = numRows;
                   fireNumRowsChanged();
         public void addDataListener(DataListener l) {
              listeners.add(l);
         public void removeDataListener(DataListener l) {
              listeners.remove(l);
         private void fireDeviationRangeChanged() {
              DataEvent event = new DataEvent(this);
              for (DataListener l : listeners) {
                   l.deviationRangeChanged(event);
         private void fireNumDeviationCategoriesChanged() {
              DataEvent event = new DataEvent(this);
              for (DataListener l : listeners) {
                   l.numDeviationCategoriesChanged(event);
         private void fireNumRowsChanged() {
              DataEvent event = new DataEvent(this);
              for (DataListener l : listeners) {
                   l.numRowsChanged(event);
    }And there are two almost trivial supporting classes to support the listener notification:
    public interface DataListener {
         public void deviationRangeChanged(DataEvent event);
         public void numDeviationCategoriesChanged(DataEvent event);
         public void numRowsChanged(DataEvent event);
    public class DataEvent {
         private final DataModel source ;
         public DataEvent(DataModel source) {
              this.source = source;
         public DataModel getSource() {
              return source;
    }The TableView exposes ObservableLists for the columns and the data. We need to update those lists when the data or column structure changes. So we need an adapter to sit in front of our generic DataModel and manipulate those lists when the data changes. This class will take a reference to a DataModel in addition to references to the column list and data list; it will listen for notifications from the DataModel and update the lists as necessary. (I'm implementing each row in the table simply as a List<String>, and we retrieve each element from the row using a custom CellValueFactory.)
    TableDataModel.java:
    public class TableDataModel {
         private DataModel model ;
         private final ObservableList<TableColumn<List<String>, ?>> columns ;
         private final ObservableList<List<String>> items ;
         public TableDataModel(DataModel model, ObservableList<TableColumn<List<String>, ?>> columns, ObservableList<List<String>> items) {
              this.model = model ;
              this.columns = columns;
              this.items = items ;
              buildColumns();
              buildItems();
              model.addDataListener(new ModelListener());
         private void buildColumns() {
              int numCols = model.getNumDeviationCategories();
              List<TableColumn<List<String>, String>> colList = new ArrayList<TableColumn<List<String>, String>>();
              double minDeviation = model.getMinDeviation() ;
              double maxDeviation = model.getMaxDeviation() ;
              double colDeviationIncrement = (maxDeviation - minDeviation) / (numCols-1) ;
              Format percentFormat = DecimalFormat.getPercentInstance();
              for (int col=0; col<numCols; col++) {
                   String colTitle = percentFormat.format(minDeviation + col*colDeviationIncrement);
                   TableColumn<List<String>, String> column = new TableColumn<List<String>, String>(colTitle);
                   final int colIndex = col ;
                   column.setCellValueFactory(new Callback<TableColumn.CellDataFeatures<List<String>,String>,ObservableValue<String>>() {
                        @Override
                        public ObservableValue<String> call(
                                  CellDataFeatures<List<String>, String> cellDataFeatures) {
                             List<String> data = cellDataFeatures.getValue();
                             return new SimpleStringProperty(data.get(colIndex));
                   colList.add(column);
              columns.clear();
              columns.addAll(colList);
         private void buildItems() {
              List<List<String>> itemList = new ArrayList<List<String>>();
              int numCols = model.getNumDeviationCategories() ;
              for (int row = 0; row<model.getNumRows(); row++) {
                   List<String> data = new ArrayList<String>();
                   double minDeviation = model.getMinDeviation() ;
                   double colDeviationIncrement = (model.getMaxDeviation() - minDeviation) / (numCols-1) ;
                   for (int col = 0 ; col < numCols; col++) {
                        double deviation = minDeviation + col * colDeviationIncrement ;
                        data.add(model.getValue(row, deviation));
                   itemList.add(data);
              items.clear();
              items.addAll(itemList);
         private class ModelListener implements DataListener {
              @Override
              public void deviationRangeChanged(DataEvent event) {
                   double minDeviation = model.getMinDeviation();
                   double maxDeviation = model.getMaxDeviation();
                   int numCols = model.getNumDeviationCategories();
                   double colDeviationIncrement = (maxDeviation - minDeviation) / (numCols-1);
                   Format percentFormat = DecimalFormat.getPercentInstance();
                   for (int col=0; col<numCols; col++) {
                        String colTitle = percentFormat.format(minDeviation + col*colDeviationIncrement);
                        columns.get(col).setText(colTitle);
              @Override
              public void numDeviationCategoriesChanged(DataEvent event) {
                   buildItems();
                   buildColumns();
              @Override
              public void numRowsChanged(DataEvent event) {
                   buildItems();
    }To test this out, I have a simple UI for changing the range of "deviations" displayed, the number of columns, and the number of rows. The controller for the UI simply instantiates a DataModel and passes calls to it when the user changes these values. In real life, of course, the changes to the data model could come from anywhere - likely from polling a server or server push. The UI also contains the TableView, retrieves the columns and items from it, and passes those, along with the data model to a TableDataModel which ties it all together. This isn't really part of the infrastructure, but for completeness here's the controller:
    Controller.java
    public class Controller {
         @FXML private TableView<List<String>> tableView ;
         @FXML private TextField minDevTF ;
         @FXML private TextField maxDevTF ;
         @FXML private TextField numColsTF ;
         @FXML private TextField numRowsTF ;
         @FXML private Button minDevIncButton ;
         @FXML private Button minDevDecButton ;
         @FXML private Button maxDevIncButton ;
         @FXML private Button maxDevDecButton ;
         @FXML private Button numColsIncButton ;
         @FXML private Button numColsDecButton ;
         @FXML private Button numRowsIncButton ;
         @FXML private Button numRowsDecButton ;
         private DataModel model ;
         public void initialize() {
              model = new DataModel(0.8, 1.2, 5, 6);
              final TableDataModel tableModel = new TableDataModel(model, tableView.getColumns(), tableView.getItems());
              model.addDataListener(new DataListener() {
                   @Override
                   public void deviationRangeChanged(DataEvent event) {
                        if (model.getMaxDeviation() - model.getMinDeviation() <= 0.01) {
                             minDevIncButton.setDisable(true);
                             maxDevDecButton.setDisable(true);
                        } else {
                             minDevIncButton.setDisable(false);
                             maxDevDecButton.setDisable(false);
                        Format percentFormat = DecimalFormat.getPercentInstance();
                        minDevTF.setText(percentFormat.format(model.getMinDeviation()));
                        maxDevTF.setText(percentFormat.format(model.getMaxDeviation()));
                   @Override
                   public void numDeviationCategoriesChanged(DataEvent event) {
                        numColsDecButton.setDisable(model.getNumDeviationCategories() <= 2);
                        numColsTF.setText(Integer.toString(model.getNumDeviationCategories()));
                   @Override
                   public void numRowsChanged(DataEvent event) {
                        numRowsDecButton.setDisable(model.getNumRows() <= 2);
                        numRowsTF.setText(Integer.toString(model.getNumRows()));
              Format percentFormat = DecimalFormat.getPercentInstance();
              minDevTF.setText(percentFormat.format(model.getMinDeviation()));
              maxDevTF.setText(percentFormat.format(model.getMaxDeviation()));
              numColsTF.setText(Integer.toString(model.getNumDeviationCategories()));
              numRowsTF.setText(Integer.toString(model.getNumRows()));
         public void decrementMinDeviation() {
              model.setMinDeviation(model.getMinDeviation() - 0.01);
         public void incrementMinDeviation() {
              model.setMinDeviation(model.getMinDeviation() + 0.01);
         public void decrementMaxDeviation() {
              model.setMaxDeviation(model.getMaxDeviation() - 0.01);
         public void incrementMaxDeviation() {
              model.setMaxDeviation(model.getMaxDeviation() + 0.01);
         public void decrementNumColumns() {
              model.setNumDeviationCategories(model.getNumDeviationCategories() - 1);
         public void incrementNumColumns() {
              model.setNumDeviationCategories(model.getNumDeviationCategories() + 1);
         public void decrementNumRows() {
              model.setNumRows(model.getNumRows() - 1);
         public void incrementNumRows() {
              model.setNumRows(model.getNumRows() + 1);
    }Here's the FXML for the UI:
    root.fxml:
    <?xml version="1.0" encoding="UTF-8"?>
    <?import javafx.scene.layout.BorderPane?>
    <?import javafx.scene.control.ScrollPane?>
    <?import javafx.scene.layout.HBox?>
    <?import javafx.scene.layout.VBox?>
    <?import javafx.scene.layout.FlowPane?>
    <?import javafx.scene.control.TextField?>
    <?import javafx.scene.control.Button?>
    <?import javafx.scene.control.Label?>
    <?import javafx.scene.control.TableView?>
    <?import javafx.scene.shape.Path?>
    <?import javafx.scene.shape.MoveTo?>
    <?import javafx.scene.shape.LineTo?>
    <?import javafx.scene.shape.ClosePath?>
    <?import javafx.scene.paint.Color?>
    <?import javafx.scene.control.ProgressIndicator?>
    <BorderPane xmlns:fx="http://javafx.com/fxml"
         fx:controller="edu.marshall.denvir.tests.gridlike.Controller">
         <top>
              <FlowPane>
                   <HBox>
                        <Label text="Min Deviation:"/>
                        <TextField fx:id="minDevTF" editable="false" />
                        <VBox>
                             <Button fx:id="minDevIncButton" prefWidth="20" prefHeight="10" minWidth="20" minHeight="10" onAction="#incrementMinDeviation">
                                  <graphic>
                                  <Path fill="BLACK">
                                       <elements>
                                            <MoveTo x="0" y="4"/>
                                            <LineTo x="2" y="0"/>
                                            <LineTo x="4" y="4"/>
                                            <ClosePath/>
                                       </elements>
                                  </Path>
                                  </graphic>                              
                             </Button>
                             <Button fx:id="minDevDecButton" prefWidth="20" prefHeight="10" minWidth="20" minHeight="10" onAction="#decrementMinDeviation">
                                  <graphic>
                                  <Path fill="BLACK">
                                       <elements>
                                            <MoveTo x="0" y="4"/>
                                            <LineTo x="2" y="0"/>
                                            <LineTo x="4" y="4"/>
                                            <ClosePath/>
                                       </elements>
                                  </Path>
                                  </graphic>                              
                             </Button>
                        </VBox>
                   </HBox>
                   <HBox>
                        <Label text="Max Deviation:" />
                        <TextField fx:id="maxDevTF" editable="false" />
                        <VBox>
                             <Button fx:id="maxDevIncButton" prefWidth="20" prefHeight="10" minWidth="20" minHeight="10"  onAction="#incrementMaxDeviation" styleClass="increment-button">
                                  <graphic>
                                  <Path fill="BLACK">
                                       <elements>
                                            <MoveTo x="0" y="4"/>
                                            <LineTo x="2" y="0"/>
                                            <LineTo x="4" y="4"/>
                                            <ClosePath/>
                                       </elements>
                                  </Path>
                                  </graphic>
                             </Button>
                             <Button fx:id="maxDevDecButton" prefWidth="20" prefHeight="10" minWidth="20" minHeight="10"  onAction="#decrementMaxDeviation">
                                  <graphic>
                                  <Path fill="BLACK">
                                       <elements>
                                            <MoveTo x="0" y="4"/>
                                            <LineTo x="2" y="0"/>
                                            <LineTo x="4" y="4"/>
                                            <ClosePath/>
                                       </elements>
                                  </Path>
                                  </graphic>
                             </Button>
                        </VBox>
                   </HBox>
                   <HBox>
                        <Label text="Number of columns:" />
                        <TextField fx:id="numColsTF" editable="false" />
                        <VBox>
                             <Button fx:id="numColsIncButton" prefWidth="20" prefHeight="10" minWidth="20" minHeight="10" onAction="#incrementNumColumns">
                                  <graphic>
                                  <Path fill="BLACK">
                                       <elements>
                                            <MoveTo x="0" y="4"/>
                                            <LineTo x="2" y="0"/>
                                            <LineTo x="4" y="4"/>
                                            <ClosePath/>
                                       </elements>
                                  </Path>
                                  </graphic>
                             </Button>
                             <Button fx:id="numColsDecButton" prefWidth="20" prefHeight="10" minWidth="20" minHeight="10" onAction="#decrementNumColumns">
                                  <graphic>
                                  <Path fill="BLACK">
                                       <elements>
                                            <MoveTo x="0" y="4"/>
                                            <LineTo x="2" y="0"/>
                                            <LineTo x="4" y="4"/>
                                            <ClosePath/>
                                       </elements>
                                  </Path>
                                  </graphic>
                             </Button>
                        </VBox>
                   </HBox>
                   <HBox>
                        <Label text="Number of Rows:" />
                        <TextField fx:id="numRowsTF" editable="false" />
                        <VBox>
                             <Button fx:id="numRowsIncButton" prefWidth="20" prefHeight="10" minWidth="20" minHeight="10"  onAction="#incrementNumRows">
                                  <graphic>
                                  <Path fill="BLACK">
                                       <elements>
                                            <MoveTo x="0" y="4"/>
                                            <LineTo x="2" y="0"/>
                                            <LineTo x="4" y="4"/>
                                            <ClosePath/>
                                       </elements>
                                  </Path>
                                  </graphic>
                             </Button>
                             <Button fx:id="numRowsDecButton" prefWidth="20" prefHeight="10" minWidth="20" minHeight="10" onAction="#decrementNumRows">
                                  <graphic>
                                  <Path fill="BLACK">
                                       <elements>
                                            <MoveTo x="0" y="4"/>
                                            <LineTo x="2" y="0"/>
                                            <LineTo x="4" y="4"/>
                                            <ClosePath/>
                                       </elements>
                                  </Path>
                                  </graphic>
                             </Button>
                        </VBox>
                   </HBox>
              </FlowPane>
         </top>
         <center>
                   <TableView fx:id="tableView"/>
         </center>
    </BorderPane>and finally the test driver:
    Gridlike.java:
    public class Gridlike extends Application {
         @Override
         public void start(Stage primaryStage) throws Exception {
              Parent root = FXMLLoader.load(getClass().getResource("root.fxml"));
              Scene scene = new Scene(root, 600, 400);
              primaryStage.setScene(scene);
              primaryStage.sizeToScene();
              primaryStage.show();
         public static void main(String[] args) {
              launch(args);
    }So that seems to me not to be too bad. Obviously in the real world there's likely to be way more functionality in the data model and table data model implementations, but the structure is pretty clean and it should integrate pretty nicely with existing structures without much effort.
    One thing I don't like is having to pass the ObservableLists to the TableDataModel. I'd prefer the TableDataModel simply to instantiate it's own lists and expose them, the way it is seems like too much strong couple from the model to the view. The problem is that the TableView only exposes ObservableLists. If it exposed ListPropertys, then those properties could just be bound to arbitrary list properties (or observable lists) exposed by a TableDataModel, which I think would be a bit cleaner.
    In terms of having APIs for binding directly from TableViews to JDBC code, or similar, I think that would be nice but is probably a bit unrealistic at this stage. What happened in the web app world was that this kind of functionality was implemented by third party frameworks, and only after the use cases had really settled down did Sun/Oracle provide standard implementations (JPA and JSF, depending on what you're looking for). I don't think we'll have to wait as long as we waited for those, but I'd guess it will be a while.
    The row headers, however, would be pretty nice, and it seems those could be fairly easily added to the TableView API. It shouldn't be too hard to create a column for them and style it so it looks different, but it would mess with the cleanliness of the data model.
    Just my $0.02 worth...

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

  • Flash 2.0 Datagrid component bug ?

    Recently I found a bug in Datagrid component. The swf file
    which contain datagrid act differely in IE 6, and IE 7.
    This is what I've done:
    1) Compile swf, export it together with html file.
    2) Run the html file
    3)Press on one of the cell,drag it and then release it
    outside of the browser/flash canvas.
    4)Move the mouse pointer back to flash canvas
    5)The grid will scroll automatically( move the move up and
    down to test)
    6)After a few times mouse pointer movement, suddenly IE
    crash, CPU usage 100%
    I have tested the swf file on firefox 2.007 and stand alone
    flash player, however, none of the flash player have this bug.
    Therefore I suspect that the ActiveX flash plugin for IE cause this
    bug.
    This is the source code, which I use to create the datagrid
    for testing.
    ps: open one fla file, drag datagrid component from component
    panel to the stage or it will not run.
    import mx.controls.DataGrid;
    var header = "Stock Code/\nName,Type,Status,Order
    Date\nTime,Duration,OrderQty/\nPrice,Matched Qty/\nPrice,Trd
    Curr/\nMatched Value,Account No/\nOrder No";
    var wid =
    "90,43.2699356842522,91.5969497381748,87.4747020181826,60.4473499934867,67.9851014914014, 90.2231829093762,111.8984058876167,134.104372277509";
    var alig = "left ,left, left , left , left , right , right ,
    right , left ";
    var halig = "center ,center,center , center , center , center
    , center , center , center ";
    var fxdata:Array = new Array();
    fxdata[0]= new Array("67676
    GPACKET","Buy","Expired","05/09/2007 06:04:20 PM","Day","200
    4.34","0 0.00","MYR 0.00","423423423432");
    fxdata[1]= new Array("054066
    FASTRAK","Buy","Expired","05/09/2007 01:45:18 PM","Day","47,900
    0.27","0 0.00","MYR 0.00","fdsfsdfsdf");
    fxdata[2]= new Array("737013
    HUBLINE","Sell","Expired","05/09/2007 11:53:19 AM","Day","400
    0.69","0 0.00","MYR 0.00","93743");
    fxdata[3]= new Array("31474
    L&G","Buy","Expired","03/09/2007 11:35:35 AM","Day","500
    0.70","0 0.00","MYR 0.00","389dskjfsd");
    fxdata[4]= new Array("38182
    GENTING","Buy","Expired","28/08/2007 11:38:59 AM","Day","500
    7.35","0 0.00","MYR 0.00","90sklsdakl");
    fxdata[5]= new Array("05005
    PALETTE","Buy","Expired","28/08/2007 11:08:23 AM","Day","500
    0.115","0 0.00","MYR 0.00","jsdaflk;as");
    fxdata[6]= new Array("093082
    GPACKET","Buy","Expired","27/08/2007 03:49:43 PM","Day","300
    3.82","0 0.00","MYR 0.00","jsdafj;sda");
    fxdata[7]= new Array("644769
    KELADI","Buy","Expired","27/08/2007 11:05:36 AM","Day","10,000
    0.30","0 0.00","MYR 0.00","jsadjf;lkdas");
    fxdata[8]= new Array("676653
    KASSETS","Buy","Expired","24/08/2007 06:15:33 PM","Day","500
    2.93","0 0.00","MYR 0.00","jlsdf;adas");
    fxdata[9]= new Array("473323
    JAKS","Buy","Expired","23/08/2007 04:45:03 PM","Day","100 0.915","0
    0.00","MYR 0.00","jjkljsdlfasd");
    fxdata[10]= new Array("03069
    IPOWER","Buy","Expired","22/08/2007 10:18:01 AM","Day","9,800
    0.365","0 0.00","MYR 0.00","jlajsd;lfjads");
    fxdata[11]= new Array("05025
    LNGRES","Buy","Expired","21/08/2007 03:08:06 PM","Day","9,900
    0.28","0 0.00","MYR 0.00","jlkjsdafl");
    fxdata[12]= new Array("01308 N2N","Buy","Expired","21/08/2007
    10:34:51 AM","Day","200 1.71","0 0.00","MYR 0.00","mjkjadsflasd");
    fxdata[13]= new Array("70069
    IPOWER","Buy","Cancelled","21/08/2007 10:02:08 AM","Day","0
    0.37","0 0.00","MYR 0.00","jkjasd;fsda");
    fxdata[14]= new Array("03069
    IPOWER","Buy","Cancelled","20/08/2007 07:20:54 PM","Day","0
    0.38","0 0.00","MYR 0.00","jkjsdlkfjsdaf");
    fxdata[15]= new Array("12651
    MRCB","Buy","Replaced","20/08/2007 05:31:59 PM","Day","900 2.35","0
    0.00","MYR 0.00","upuewoirwe");
    var mdtgrid:DataGrid;
    _root.createEmptyMovieClip("displayobj1",
    _root.getNextHighestDepth(),{_x:0,_y:0});
    initial();
    function initial(){
    _root.mdtgrid =
    _root.createClassObject(mx.controls.DataGrid, "xxx",
    _root.getNextHighestDepth());
    _root.mdtgrid.doLater(_root,"setData");
    function setData(){ //insert data to datagrid
    var temp:Array = new Array();
    for (var i in _root.fxdata){
    temp
    = new Object();
    for (var j in _root.fxdata){
    temp
    [j] = _root.fxdata[j];
    _root.mdtgrid.dataProvider =temp;
    _root.mdtgrid.doLater(_root,"setdgStyle");
    function setdgStyle(){
    var rowhight = 40;
    var noofrow = 8;
    var headerheight = 35;
    var gridheight = (rowhight * noofrow) + headerheight ;
    _root.mdtgrid.setSize(800, gridheight);
    _root.mdtgrid.rowHeight =rowhight;
    _root.setHeader(_root.header.split(","));
    _root.setWidth(_root.wid.split(","));
    _root.setAlign(_root.alig.split(","));
    _root.mdtgrid.invalidate();
    function setHeader(datasource:Array){ //set header label
    var leng:Number = _root.mdtgrid.columnCount;
    var sleng:Number = datasource.length;
    var temp:Object;
    for (i =0 ;i<leng;i++){
    if (i>=sleng){
    break;
    _root.mdtgrid.getColumnAt(i).headerText = datasource
    function setWidth(datasource:Array){ //set columns width
    var leng:Number = _root.mdtgrid.columnCount;
    var sleng:Number = datasource.length;
    var temp:Object;
    for (i =0 ;i<leng;i++){
    if (i>=sleng){
    break;
    _root.mdtgrid.getColumnAt(i).width = Number(datasource);
    function setAlign(datasource:Array){ //set Alignment
    var leng:Number = _root.mdtgrid.columnCount;
    var sleng:Number = datasource.length;
    var temp:Object;
    for (i =0 ;i<leng;i++){
    if (i>=sleng){
    break;
    temp = _root.mdtgrid.getColumnAt(i);
    temp.setStyle("textAlign",trim(datasource

    Anyone know how to fix it ?

  • How to read context node/attribute data of diff UI component of same screen

    Hi,
    I am new to CRM and as well as BSP, Now the requirement is, at the time of Lead creation, when the end user enters customer code and sales area i need to fetch and display the customer group 1 value( VIP,KAM etc) based on the customer's sales area, ( these are sales area specific values).
    but the problem is Customer code is in diff UI component and sales area data is in diff UI component .
    1) customer code attribute is in UI component BT108H_LEA, View BT108H_LEA\Detail, Context node is BTPARTNERPROSPECT.
    2) sales area fields are in the UI component BTORGSET, View BTORGSET\OrgSetData, Context node is BTORGSET.
    3) I have created new field(customer type to display the customer group 1 value "VIP") in UI component BT108H_LEA, View BT108H_LEA\Detail, Context node is BTLEADH.    
    To display the value in the context node BTLEADH, i need to know the sales area data which is entered in BTORGSET.
    Kindly let me know how to read the data which is in diff UI component of the same Lead creation screen.
    i written following code in context node BTLEADH, atttribute New Zfield, in get method, but not able solve, please guide me.
      DATA: LR_ENT TYPE REF TO CL_CRM_BOL_ENTITY,
                 LR_COL TYPE REF TO IF_BOL_ENTITY_COL.
      LR_ENT ?= ME->TYPED_CONTEXT->BuilHeader->COLLECTION_WRAPPER->GET_CURRENT( ).
      LR_COL = LR_ENT->GET_RELATED_ENTITIES( IV_RELATION_NAME = 'BuilSalesArrangementRel' ).
      LR_ENT ?= LR_COL->GET_FIRST( ).
      IF LR_ENT IS BOUND.
        LR_ENT->GET_PROPERTY_AS_VALUE( EXPORTING IV_ATTR_NAME = 'DIVISION'  IMPORTING EV_RESULT =  LV_DIVISION  ).
      ENDIF.
    I'll appreciate if you can provide me some documents to refer.
    awaiting for your responses.
    Thanks
    Bhanu

    Hi Gangadhar,
    I think i have not clearly explained my requirement, let me put it once again. My requirement is, I have to read two UI component data, validate and display some value in one new zfield which is in one of the UI components.
    I need to display customer's sales area specific data like customer group 1 value in that new zfield. for that i need Customer code and as well as sales area data from the screen.
    1) customer code attribute is in UI component BT108H_LEA, View BT108H_LEA\Detail, Context node is BTPARTNERPROSPECT.
    2) sales area fields are in the UI component BTORGSET, View BTORGSET\OrgSetData, Context node is BTORGSET.
    3) I have created new field(customer type to display the customer group 1 value "VIP") in UI component BT108H_LEA, View BT108H_LEA\Detail, Context node is BTLEADH.
    As per my understanding, in the context node BTLEADH, GET_METHOD of atttribute New Zfield, i have to read customer code from UI component BT108H_LEA, View BT108H_LEA\Detail, Context node is BTPARTNERPROSPECT and Sales area data from UI component BTORGSET, View BTORGSET\OrgSetData, Context node is BTORGSET based on the values, validate and display the data.
    But as per your recent reply you are asking me to write the code in get_property_attribute---division. so i didnt understand.
    Kindly clarify if i am wrong.
    awaiting for your response.
    Thanks
    BHanu

  • Webi 4.0 Custom Sort for SSAS Hierarchy

    Hi,
    I'm using SSAS cube as a source for my webi report .Some report need custom sorting for hierarchy object , we are not able to apply sorting correctly in webi.
    What do i need to do in order to apply the custom sorting for hierarchy object?  Thanks.

    Hi, I've written a post on this:
    http://blog.davidg.com.au/2011/09/dynamic-measures-in-webi-on-any-data.html
    ...and a few people in the comments seemed to have the same problem as you, which seems to be a bug (clicking the ellipsis does not launch the custom values screen).
    Perhaps you could try the solution offered by Gallin, which was to create a second input control, then retry the steps to create another input control and click the ellipsis to enter custom values.
    Hope that helps.

  • Custom Sort

    I have a wierd problem that has been causing me quite a few headaches and i think if there is a way to do a custom order by, it might get rid of this annoynce.
    I have an existing script that is five scripts unioned together. When i run the script on it's own, i get the desired result in the desired order, but when i run it through a data window in powerbuilder it is bringing back a different order and i can't figure out why. It's the exact same script.
    Anyways, i'm wondering if i can create a custom sort order by, so that i can specify what the first and second fields are and then let the rest fall as they are supposed to:
    Here is a look at my Current results:
    Equip_# - Read_Desc - Date ----------- Reading
    12345 - Consumption - 10/05/2008 - 1101.88
    12345 - Consumption - 10/05/2008 - 0000.00
    12345 - Summer Peak- 10/05/2008 - 0000.00
    12345 - Winter Peak - 10/05/2008 - 0000.00
    12345 - Radio Device - 10/05/2008 - 0000.00
    12345 - Demand ------- 10/05/2008 - 0000.00
    I need the first two fields of the table to sorted as follows and then the rest can just fall into place:
    Equip_# - Read_Desc - Date ----------- Reading
    12345 - Consumption - 10/05/2008 - 1101.88
    12345 - Demand ------- 10/05/2008 - 0000.00
    ...Doesn't matter how it sorts as long as they two come first
    Hope someone can help, cause this really just doens't make a lot of sense and i'm now just trying to get this done and get it behind me.
    thanks in advance

    Justin Cave wrote:
    Can you post the actual SQL statement you are using (or at least the skeleton structure)? You want the ORDER BY to apply to the entire result, not to one individual subquery that is getting unioned with a number of other subqueries.
    Is PowerBuilder trying to order the data before displaying it? Obviously, the GUI is free to disregard the order Oracle happens to return results if you've instructed it to sort the data differently.
    JustinI don't believe powerbuilder is trying to order the data before displaying it. If it is, it's in a place not easily seen.
    Here is my code:
    SELECT equipment.equipment_number,
    read_class.read_class_desc,
    meter_read.effective_date,
    meter_read.meter_read,' ',' ',' ',''seal_broken,'1'
    FROM equipment,
    meter_read,
    meter_read_class,
                   equipment_type,
                   equipment_class,
                   read_class
    WHERE meter_read.meter_read_class_id = meter_read_class.meter_read_class_id and
    meter_read.equipment_id = equipment.equipment_id and
                   equipment.equipment_type_id = equipment_type.equipment_type_id and
                   equipment_type.equipment_class= equipment_class. equipment_class and
                   meter_read_class.read_class =read_class.read_class and     
    equipment_class.equipment_category = 'EMETER' AND
    equipment.current_service_id = 32399 and
                   meter_read_class.read_class = 'ECONSUME' and
                   meter_read.effective_date=
                   (select max(mr.effective_date)
                        from equipment e,
    meter_read mr,
    meter_read_class mrc,
                   equipment_type et,
                   equipment_class ec
    WHERE mr.meter_read_class_id = mrc.meter_read_class_id and
    mr.equipment_id = e.equipment_id and
                   e.equipment_type_id = et.equipment_type_id and
                   et.equipment_class= ec. equipment_class and
    ec.equipment_category = 'EMETER' AND
    e.current_service_id = 32399 and
                   mrc.read_class = 'ECONSUME')
    union SELECT equipment.equipment_number,
    read_class.read_class_desc,
    meter_read.effective_date,
    meter_read.meter_read,' ',' ',' ',''seal_broken,'2'
    FROM equipment,
    meter_read,
    meter_read_class,
                   equipment_type,
                   equipment_class,
                   read_class
    WHERE meter_read.meter_read_class_id = meter_read_class.meter_read_class_id and
    meter_read.equipment_id = equipment.equipment_id and
                   equipment.equipment_type_id = equipment_type.equipment_type_id and
                   equipment_type.equipment_class= equipment_class.equipment_class and
    equipment_class.equipment_category = 'EMETER' AND
    equipment.current_service_id = 32399 and
                   meter_read_class.read_class = 'DEMAND' and
    --               read_class.read_class_desc not in ('Electrical Consumption', 'Electrical ERT Device') and
                   meter_read.effective_date=
                   (select max(mr.effective_date)
                        from equipment e,
    meter_read mr,
    meter_read_class mrc,
                   equipment_type et,
                   equipment_class ec
    WHERE mr.meter_read_class_id = mrc.meter_read_class_id and
    mr.equipment_id = e.equipment_id and
                   e.equipment_type_id = et.equipment_type_id and
                   et.equipment_class= ec. equipment_class and
    ec.equipment_category = 'EMETER' AND
    e.current_service_id = 32399 and
                   mrc.read_class = 'DEMAND' )
    order by meter_read, decode(read_class_desc,'Electrical Consumption',1,'Electrical Demand',2), read_class_desc
    I've only recently tried entering in the decode in the order by, as someone else suggested and it works fine for individual queries, but when i use it against the whole query (including the Union's), i get the following error:
    ORA-01785: ORDER BY item must be the number of a SELECT-list expression

  • Lightroom Mobile does not recognise my custom sort order

    I cannot find a way to get the Lightroom Mobile app on my iPad to recognise the custom sort order set up for the collection on my desktop. I am on the current versions of both Lightroom and Lightroom Mobile. The only sort option that appears in LR mobile is by capture time. The custom sort order is available as an option for the collection on the Abobe website but not on the mobile app.

    You can change the sort type when you touch the Capture Type-label. So tab on the "Capture Time"-label and you will see the other sort options like "Modified Date", "Custom Order" etc.
    Hope that helps.
    -guido

  • Date Validation on Datagrid

    Hey guys i have a web app that basically has a browse button  and when the user clicks  the button it prompts for a file on their PC and loads a datagrid.
    My question is rather simple. How do I validate the date columns on datagrid so that it should be formatted like so 17-MAR-10 and not anything other then that. i have a done validation on datagrid with custom classes i built but i have no idea how to go about validating an specific formatt.
    Any Help would be greatly appreciated.
    Thanks
    Miguel

    two assumptions:
    if you need to show the date in your format - then use itemrenderer or labelfunction.
    if you need to show only the rows with that format, then filter the arraycollection - the data provider.

  • Tracks sorted by date / album / track number

    Hello,
    I always display my tracks sorted by date added, because I like to see my newest records first. This way the new "album view", with the sleeve on the left of the tracks, looks good.
    Except there is something really annoying, because it is sorted by date, it seems to be strictly sorted by date, and the tracks do not show in the correct order, more in the order, seond by second, they were added to the library.
    Is there a way to make the tracks show by date added, but within one album sorted by song order ?
    Thanks

    The link should have taken you to my scripts page, where clicking on the name of the script should have given you a file to download called SortDateAdded.vbs. Assuming you saved this without changing the .vbs extension then I'm not sure why it doesn't work. I'm pretty sure Vista should support VBScript without any extra effort, but I'll have a hunt around and see what I can find out. Perhaps there is some optional component that was excluded during your Vista install.
    Ah... try this link: http://colinwetherbee.com/weblog/archives/2007/04/vbscriptnotre.html
    tt2
    Message was edited by: turingtest2

Maybe you are looking for

  • SSO is not working for SAPGUI for HTML

    Hi Experts, We have configured SSO between EP and ECC.SSO is working fine for SAPGUI for windows.But it is not working for SAPGUI for HTML. Workflow iViews are getting error. "SWITCH to HTTPS does not occur." The domain names are different for EP and

  • Restore lost iphoto library (iphoto v.8)

    Hi, I was making an iMovie and when I hooked up my DV camera it would not load the camera and an error came up and said you should put away in finder or data will be lost. Well I thought that was the camera not my external hard drive. The cables are

  • How to Factory Reset a Cisco 6160

    I can't figure this out and there isn't much documentation on the subject online. The reset button just resets the device even after holding it for 10+ seconds and there is nothing in the CLI.

  • Workspace Flex projects

    I have a  workspace with two projects. Project #1 references an external SWC library. Project #2 references SWC #1. Do I also need to referecence an external SWC library in projecct #2? Thanks

  • Why does photoshop elements 12 freeze when trying to save an image for the web?

    Everytime I try to save an animated GIF image for the web the whole application freezes and I have to force quit.  The file sizes are small.  Can someone help me with this issue?