Enable multiple selection in spark datagrid

Hi guys, I am trying to enable multiple selection in my datagrid. I tried allowMultipleSelection=true but it didn't have that attribute on spark component. Anyone knows how to do it? Thanks a lot.

Use selectionMode="mutipleRows"
http://help.adobe.com/en_US/flex/using/WS0ab2a460655f2dc3-427f401412c60d04dca-7ff8.html

Similar Messages

  • Drag selection in spark datagrid?

    Is there an easy way to enable a spark DataGrid to use drag selection, similar to how you can select cells in Excel or Google Docs? Or will I need to track mouse movements and manually manipulate the selectedCells?
    Thanks!
    -Aaron

    Couldn't find a built in way to do this, but it turned out to be pretty easy thanks to the GridEvent classes that solve the challenge of know what row/column index the mouse is interacting with. My final solution:
    A class that extends spark::DataGrid
    private var _allowDragSelection:Boolean = false;
    private var dragSelectionAnchor:CellPosition;
    private var dragSelectionStarted:Boolean;
    * If true and selectionMode is GridSelectionMode.MULTIPLE_CELLS the user can drag their
    * mouse to select a rectangular area of cells, just like Excel or Google Docs.
    public function get allowDragSelection():Boolean { return this._allowDragSelection; }
    public function set allowDragSelection(value:Boolean):void {
              if(this._allowDragSelection == value)
                        return;
              this._allowDragSelection = value;
              if(this.allowDragSelection)
                        this.addEventListener(GridEvent.GRID_MOUSE_DOWN, this.handleGridMouseDown);
              else
                        this.removeEventListener(GridEvent.GRID_MOUSE_DOWN, this.handleGridMouseDown);
    private function handleGridMouseDown(e:GridEvent):void {
              if(this.selectionMode != GridSelectionMode.MULTIPLE_CELLS)
                        return;
              this.dragSelectionAnchor = new CellPosition(e.rowIndex, e.columnIndex);
              this.dragSelectionStarted = false;
              this.addEventListener(GridEvent.GRID_MOUSE_DRAG, this.handleGridMouseDrag);
              this.stage.addEventListener(MouseEvent.MOUSE_UP, this.handleDragMouseUp);
    private function handleGridMouseDrag(e:GridEvent):void {
              // don't start processing selection drag until mouse has left the selection anchor
              if(!this.dragSelectionStarted && e.rowIndex == this.dragSelectionAnchor.rowIndex && e.columnIndex == this.dragSelectionAnchor.columnIndex)
                        return;
              // once started, process changes even if the user drags back over the anchor
              this.dragSelectionStarted = true;
              // local to avoid expensive getter cost
              const selectedCells:Vector.<CellPosition> = e.grid.selectedCells;
              // determine the selection rectangle from the anchor to the current cell
              const rowFromIndex:int = Math.min(this.dragSelectionAnchor.rowIndex, e.rowIndex);
              const rowToIndex:int = Math.max(this.dragSelectionAnchor.rowIndex, e.rowIndex);
              const colFromIndex:int = Math.min(this.dragSelectionAnchor.columnIndex, e.columnIndex);
              const colToIndex:int = Math.max(this.dragSelectionAnchor.columnIndex, e.columnIndex);
              // create new cell positions selection vector, and track if any new cell is added
              var cells:Vector.<CellPosition> = new Vector.<CellPosition>();
              var cellsChanged:Boolean = false;
              for(var row:int = rowFromIndex; row <= rowToIndex; row++){
                        for(var col:int = colFromIndex; col <= colToIndex; col++){
                                  var cell:CellPosition = new CellPosition(row, col);
                                  cells.push(cell);
                                  cellsChanged = cellsChanged || !selectedCells.some(function(c:CellPosition, i:int, v:Vector.<CellPosition>):Boolean {
                                            return c.rowIndex == cell.rowIndex && c.columnIndex == cell.columnIndex;
              // assign the new selection only if it changed (Flex is pretty slow here with big selections)
              if(cellsChanged || selectedCells.length != cells.length){
                        this.selectedCells = cells;
                        // maintain the selection anchor for any following SHIFT click selection
                        this.grid.anchorRowIndex = rowFromIndex;
                        this.grid.anchorColumnIndex = colFromIndex;
    private function handleDragMouseUp(e:MouseEvent):void {
              this.removeEventListener(GridEvent.GRID_MOUSE_DRAG, this.handleGridMouseDrag);
              this.stage.removeEventListener(MouseEvent.MOUSE_UP, this.handleDragMouseUp);
    Cheers.
    -Aaron

  • To enable multiple selection for tree view in web ui .

    Hi Experts ,
    We have requirement to add a multiple selection to a tree view in web ui  for a standard view.
    Component: BP_HIER
    View: BP_HIER/EOVPHierarchyTreeV
    Currently only single select is enabled for this view. I have added the following code in the HTMl page to multi selection.
    selectionMode          = "<%= AccountHierarchy->selection_mode %>"
    <%--selectedRowIndexTable = "<%= AccountHierarchy->SELECTION_TAB %>"--%>
    And in "DO_INIT_CONTEXT " method I have added the following code to enable multi select.
    typed_context->accounthierarchy->set_selection_mode(
            iv_selection_mode = cl_bsp_wd_context_node_tv=>selmode_multi.
    But still multi selection is not working.
    Let me know if any code changes are required in method "EH_ONSELECT" to enable multi selection.
    Regards,
    Shweta Nimje

    Hi Shweta,
    Why did you comment attribute selectedRowIndexTable? Uncomment and try again.
    selectedRowIndexTable = "<%= AccountHierarchy->SELECTION_TAB %>"

  • How do i select multiple items in spark list without pressing the control ?

    Hi all,
    I need to change the list behavioral to enable multiple selections with a click on each item
    In list, instead of using the control
    10x
    elazar r

    In your itemClick handler, check the selectedItems property, and add to it. You might need to maintain a separate collection object and bind the selectedItems property to it.
    The question becomes how to unselect an item. If it is already selected, clicking it again can unselect it, and clicking a submit button or comparable action could do the same.
    If this post answers your question or helps, please mark it as such. Thanks!
    http://www.stardustsystems.com
    Adobe Flex Development and Support Services

  • Datagrid multiple selection

    Hello
    My client wants to have a possibility of multiple selections
    in a datagrid... but he wants to have them selected by a simple
    click instead of the "classical" ctrl click... how can I achieve
    that ?
    Henri

    What you can do is use the selectedIndices property of the
    grid. Keep a
    separate array - call it indices. When a click on the grid is
    made, get the
    grids.selectedIndex and then add that to you indices array.
    Then set the
    grids.selectedIndices to your indices array. Make sure you
    set the grids
    multipleSelection property to true.
    Dave -
    Head Developer
    http://www.blurredistinction.com
    Adobe Community Expert
    http://www.adobe.com/communities/experts/

  • Check Box in Tree (tree multiple selection)

    I need to create a 2 level hierarchy tree, where the user is allowed to make multiple selection on leaf node. One way is to use TableTree (TreeByNestingTableColumn), but with this I am unable to get the same look and feel of a simple Tree view.
    My questions are:
    1. Is there a way to enable multiple selection on a simple Tree?
    2. If the answer to question 1 is no, then is there a way to add check boxes to the Tree elements (be it parent or leaf)?
    3. Is there anything that can be done to solve this issue without using TableTree?
    Thanks in advance.

    Hi,
    Please go through Multiselection in Tree control thread.
    The solution outline is like this:
    1. When you click on a leaf, you mark it as selected and you can also store it in the context.
    2. Click as many leaves as you like and the onAction will mark each of them as selected.
    3. There's no need to do a CTRL+click, only normal clicks.
    4. Once done you can find out all the marked leaves.
    Regards,
    Satyajit.

  • Multiple selection in JTable

    Hi ,
    The problem is to select multiple rows and columns in the JTable like that of a excel application and have the focus on the first column of the last row. for example if select cells from ( 1,1 ) to ( 4,4), after selection the focus should be in cell (4,1). i have written a prgram( which is below) which uses listSelection to find out the cells which are selected. i found out the cells which are selected also. but i do not know how to get the focus on that cell. i have attached the code below also.. i want to know whether there is any method which set the focus to the particular cell. Can the problem above can be solved in any other way..or a simpler way..
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    class myTable {
    public static void main(String a[] ) {
              JFrame myframe = new JFrame();
              JTable jtable = new JTable(10,10);
              jtable.setCellSelectionEnabled(true);
         // add the listener to the table
    ListSelectionModel listSelectionModel;
         OSSTableSelectionHandler obj = new OSSTableSelectionHandler(jtable,10,10);
         listSelectionModel = jtable.getSelectionModel();
    listSelectionModel.addListSelectionListener(obj);
         myframe.getContentPane().add(jtable);
         myframe.show();
    } // end of public static void main
    } // end of class of myTable
    class OSSTableSelectionHandler implements ListSelectionListener {
                   JTable table;
         int row;
                   int col;
    OSSTableSelectionHandler(JTable tab, int r, int c ) {
         table = tab;
    row = r;
              col = c;
    public void valueChanged(ListSelectionEvent e) {
    ListSelectionModel lsm = (ListSelectionModel)e.getSource();
                   int i = 0,j = 0;
    int firstIndex = e.getFirstIndex();
    int lastIndex = e.getLastIndex();
    boolean isAdjusting = e.getValueIsAdjusting();
    if (lsm.isSelectionEmpty()) {
    System.out.println(" Selection empty ");
    } else {
    // Find out which indexes are selected.
                        int maxrow = 0 ;
    int minIndex = lsm.getMinSelectionIndex();
    int maxIndex = lsm.getMaxSelectionIndex();
    for ( i = minIndex; i <= maxIndex; i++) {
    if (lsm.isSelectedIndex(i)) {
                                  if ( maxrow < i )
                                       maxrow = i;
                                  for (j = 0;j < col ;j++ )
                                       if ( table.isCellSelected(i,j) )
                                            System.out.println("The selected index is " + i + " " + j);
                             } // end of if                    
    } // end of for
                   // after this maxrow contains the last row that has beeb selected
                   // this for loop is to find out the first column in the maxrow that is selected
                   for (j = 0;j < col ;j ++ )
                        if ( table.isCellSelected(maxrow,j) )
                                  break;
                   // set the focus to the column ( maxrow, j )
    } // end of else
    } // end of fucn value changed
    } // end of class OSSTableSelectionHandler

    Whic cell is focused depends on where you begin your selection. The cell that you press your mouse first will be the focused one. Here is how I implement the mutiple selection functionality in a JTable as what MS Excel provides. This class is independent of my any other package. your table has to have column headers and a upper left JLabel corner(int the scroll pane containing the table) in order to make this class which I named TableSelectionAdapter function properly. You can revise and imporve it as you need, however.
    package petrochina.riped.gui.table.tableadapter;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import javax.swing.event.*;
    import java.awt.datatransfer.*;
    import java.util.*;
    * Enables multiple selection funtionality on <code>JTable</code>s.
    * @author Guanglin Du,SEC of Riped, PetroChina,
    * [email protected]
    * @version 1.0 2002/09/16
    public class TableSelectionAdapter extends MouseAdapter {
    private String newline = "\n";
    private boolean DEBUG = false;
    // private boolean DEBUG = true;
    private JTable myTable = null;
    private boolean shiftKeyDown = false;
    private boolean ctrlKeyDown = false;
    private int firstSelectedColIndex = -1;
    * Constructs with a <code>myTable</code> to simplify its reusability.
    * Guanglin Du, 2002/09/19
    * @param myTable     a <code>JTable</code>
    public TableSelectionAdapter(JTable myTable) {      
    this.myTable = myTable;
    initTableSelection();
    * The initTableSelection method: initializes the row/column/cell
    * selection functionality of the table.
    * Guanglin Du, 2002/09/19
    public void initTableSelection() {      
    getMyTable().setSelectionMode(
              ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
         //Cell selection
         myTable.addMouseListener(new MouseAdapter() {
         public void mousePressed(MouseEvent e) {
              myTable.setColumnSelectionAllowed(true);
              myTable.setRowSelectionAllowed(true);
         setMyKeyListener(); //shift/control key listener
         //column selection functionality
         JTableHeader myTableHeader = getMyTable().getTableHeader();
         myTableHeader.addMouseListener(new TableHeaderListener());
         //enalbles select-all functionality
         setSelectAllFunction();
    * This setSelectAllFunction isto set the select-all functionality
    * when the upper left corner label of the JTable is clicked.
    * Note: JTable's parent JScrollPane has to be found.
    * Guanglin Du, 2002/09/19
    public void setSelectAllFunction() {      
    Container firstParent = getMyTable().getParent();
    if (firstParent instanceof JViewport) {
         Container secondParent = firstParent.getParent();
         if (secondParent instanceof JScrollPane) {
         JScrollPane myScrollPane = (JScrollPane)secondParent;
         JLabel myLabel =
              (JLabel)myScrollPane.getCorner(JScrollPane.UPPER_LEFT_CORNER );
         myLabel.addMouseListener(this);
    * Detects shift/control key state.
    * DGL, 2002/09/18
    public void setMyKeyListener() {
         getMyTable().addKeyListener(new KeyAdapter(){               
         //keyPressed
         public void keyPressed(KeyEvent e){
              //shift key state
              if(e.isShiftDown())     shiftKeyDown = true;                    
              //control key state
              if(e.isControlDown()) ctrlKeyDown = true;
    //keyReleased
         public void keyReleased(KeyEvent e){
              //shift key state
              if( !e.isShiftDown() ) shiftKeyDown = false;                    
              //control key state
              if( !e.isControlDown() ) ctrlKeyDown = false;
    * Adds the table header listener to enable single/multiple column selection.
    * DGL, 2002/09/17
    public void setTableHeaderListener() {
         JTableHeader myTableHeader = myTable.getTableHeader();
         myTableHeader.addMouseListener(new TableHeaderListener());
    * Returns the <code>myTable</code> property value.
    * @return myTable the table that this class handles
    public JTable getMyTable() {
    return myTable;
    * Sets <code>myTable</code> property value of this class.
    * @param myTable the table that this class handles
    public void setJTable(JTable myTable) {
         this.myTable = myTable;
    * Returns the shiftKeyDown property value.
    * @return boolean, Guanglin Du, 2002/09/18
    public boolean getShiftKeyDown(){
         return shiftKeyDown;
    * Return the ctrlKeyDown property value.
    * @return boolean, Guanglin Du, 2002/09/18
    public boolean getCtrlKeyDown(){
         return ctrlKeyDown;
    * This inner class handles the column selection, the same
    * behavior as MS Excel.
    * Guanglin Du, 2002/09/18
    class TableHeaderListener extends MouseAdapter {
    public void mousePressed(MouseEvent e) {    
         stopLatestCellEditing(); //To save the data being edited
         if(DEBUG) System.out.print("mousePressed on ");
         JTableHeader myColumnHeader = (JTableHeader)e.getSource();
         Point myPoint = e.getPoint();
         int selectedColIndex = myColumnHeader.columnAtPoint(myPoint);
         if(DEBUG) System.out.print("the header of column "
              + selectedColIndex+newline);
         JTable table = myColumnHeader.getTable();
         //The following column selection methods work only if these
         //properties are set this way
         table.setColumnSelectionAllowed(true);
         table.setRowSelectionAllowed(false);
         int myRowCount = table.getRowCount();
         //makes this table focused, so that setMyKeyListener method can
         //listen for shift/control KeyEvent
         table.requestFocus();
    //     System.out.println("myRowCount = " + myRowCount);
         if( getShiftKeyDown() ){
         table.clearSelection();
         table.setRowSelectionInterval(0,myRowCount-1);
         table.setColumnSelectionInterval(selectedColIndex,selectedColIndex);
         if(firstSelectedColIndex > -1) {
              table.addColumnSelectionInterval(firstSelectedColIndex, selectedColIndex);
              firstSelectedColIndex = -1;//restore to -1
         } else if( getCtrlKeyDown() ) {
         table.addRowSelectionInterval(0,myRowCount-1);
         table.addColumnSelectionInterval(selectedColIndex,selectedColIndex);
         } else {
         table.clearSelection();
         table.setRowSelectionInterval(0,myRowCount-1);
         table.setColumnSelectionInterval(selectedColIndex,selectedColIndex);
         if(DEBUG) System.out.println("shiftKeyDown = " + shiftKeyDown
              +";"+" ctrlKeyDown = " + ctrlKeyDown);     
         //saves the first selected column index
         firstSelectedColIndex = selectedColIndex;
    * MouseAdapter implemenation.
    * mousePressed: sets the select-all functionality
    * when upper left corner label of the table is clicked
    * Guanglin Du, 2002/09/18
    public void mousePressed(MouseEvent e) {    
         if(DEBUG) System.out.println("Select all");
         stopLatestCellEditing();//To save the data in editing
         getMyTable().selectAll();
    * Triggers the latest <code>ActionEvent</code> in a table cell to save
    * the latest data. Or, the newly input data will not be stored into the table
    * model and cannot be retrieved.
    public void stopLatestCellEditing() {
    int editingRow = getMyTable().getEditingRow();
    int editingCol = getMyTable().getEditingColumn();
    if (editingRow != -1 && editingCol != -1){
         TableCellEditor cellEditor =
         getMyTable().getCellEditor(editingRow, editingCol);
         cellEditor.stopCellEditing();
    Here is how you can use it in your coding(where myTable is a JTable instance you create):
         /* Adds TableSelectionAdapter to enable all kinds of selection action. */
         TableSelectionAdapter tableSelect = new TableSelectionAdapter(myTable);     

  • Listbox with multiple selection in interactive forms

    Hello experts.
    I'd like to use a listbox in my form with enabled multiple selection.
    The form is part of a WebDynpro ABAP Application.
    Reading the context to get the content of the form fields works fine as long as I don't use a list box where
    multiple selection is enabled.
    When I use the box I only get the values of all other fields, but not the selected values of the box.
    My context node for the pdf looks like this:
    - *Node for PDF*  (Cardinality 1..1; Selection 0..1)
    -- Attribute 1
    -- Attribute2
    -- Node for Listbox (Cardinality 0..n; Selection 0..n)
    --- Attribute for Listbox
    Please help!
    Regards
    Frank
    Edited by: Frank Mueller on Feb 6, 2008 10:31 AM

    Hi,
    is there really nobody who knows, how to give more when one selected item of a list box back to ABAP?
    Please help!
    Regards
    Frank

  • Talent search: advanced search multiple selection

    Dear Guru's
    We have setup the TREX and are using the advanced search for talent management. Everything is working fine except if we use the multiple selection option for a field. We have definied our own search field to search for (a range of) salary scale. However if we use the multiple selection and  try to search for e.g. range 05 till 07 the engine only searches for the 05 value and not for 06 and 07. This also appears using  ESH_TEST_SEARCH and also appears within SAP fields such as organizational unit etc.
    We are on SAPBASIS SAPKB70210
                    SAPHR      SAPKE60460  
    Any suggestions ?
    Kind regards Stephan

    Hi Stephan,
    It looks like you're on 604 SP 60 but it's component EA-HRGXX that is important to check. These SAP Notes are useful to implement for the Advanced Search and do cover some of your symptoms.
    1548337 - Search: Enabling multiple selection (EHP 4)
    1550930 - Search: Various corrections for the advanced search
    1561778 - Search: Adding combination in an MV dialog box
    1561031 - Search: Various corrections for the advanced search #2
    Best regards,
    Luke

  • Multiple Selection Upload from Clipboard

    hi experts
    I am looking to see if anyone has any information on how to get the Multiple Selection Upload from Clipboard functionality into the webUI as we had in the SAPGUI. 
    An example of how this is used is by going in the SAPGUI to /BEA/CRMB01 - Maintain Billing Due List  and under billing document, clicking the arrow on the right which enables multiple selection and upload via clipboard.
    Thanks for your help!
    Chris

    HI Prashanth,
    Not as of now, ranges can be an option though, if they can be applied. If you have maintained the Ids since the start of the implementation following some stanrds then its good or otherwise it might be a re-work to type again and again and concatenate the results.
    Regards,
    Hersh.

  • How to handle multiple selection in the Spark List control with checkbox as itemrenderer?

    Hi All,
    I am using checkbox as an ItemRenderer in spark list.
    I have a query.
    how to handle multiple selection in the Spark List control with checkbox as itemrenderer?
    how to retrieve the selected item label?
    Thank you in advance.

    Hi there, I'll tweak your code a little bit to something like this:
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                    layout="vertical">
        <mx:Script>
            <![CDATA[
                 import mx.events.ListEvent;
                 import mx.controls.CheckBox;
               [Bindable]
               private var mySelectedIndexes:ArrayCollection=new ArrayCollection();
                private function onChange(e:ListEvent):void
                   if(CheckBox(e.itemRenderer).selected){
                             mySelectedIndexes.addItem(e.rowIndex);
                   }else{
                                  mySelectedIndexes.removeItemAt(mySelectedIndexes.getItemIndex(e.rowIndex));     
                   chkList.selectedIndices=mySelectedIndexes.toArray();
            ]]>
        </mx:Script>
    <mx:ArrayCollection id="collection">
            <mx:Object label="Test A"/>
            <mx:Object label="Test B"/>
            <mx:Object label="Test C"/>
            <mx:Object label="Test D"/>
            <mx:Object label="Test E"/>
            <mx:Object label="Test F"/>
            <mx:Object label="Test G"/>
        </mx:ArrayCollection>
    <mx:List id="chkList" dataProvider="{collection}" itemRenderer="mx.controls.CheckBox"  itemClick="onChange(event);" allowMultipleSelection="true"/>
    </mx:Application>

  • How To Enable a List Box To accept  Multiple Selection

    Dear all,
    How can I enable a List box to accept multiple selection.If any body can please help me.
    Thanks a bunch in advance
    Regards
    Rakesh

    The only problem is, the XML form data only contains the first selection made. All others are discarded. This is the first thing I've ever done with the Life Cycle Designer but the product seems somewhat in a version 1 state. Lots of features but no depth. Any suggestions about the XML?

  • Multiple selection should enable the check box item next to the field

    Hi,
    I want multiple selection for " Environment" field in the Form. Once muliple values are selected, user needs to see a checkbox next to all the values selected in Environment field.
    Checkbox field should be called as ' Implemented'.
    For ex. In Environment Field, I selected three values, I should see checkbox against each selected environments:
    col 1:I Environment col:2 Implemented
    Env1 X
    Env2 X
    Env2 X
    X-> refers to checkbox.
    Please suggest something if anyone have tried this one.
    Thanks in advance.
    Regards,
    Ramya

    hello Ramya,
    In Environment Field, I selected three values, I should see checkbox against each selected environmentsyou can write Post-Change trigger or When-Validate-Item trigger on Column 1 say: txt_environment and in the trigger, write down the following code
              set_item_property('BLOCK.TXT_CHECKBOX',VISIBLE,PROPERTY_TRUE);
              set_item_property('BLOCK.TXT_CHECKBOX',ENABLED,PROPERTY_TRUE);
              set_item_property('BLOCK.TXT_CHECKBOX',NAVIGABLE,PROPERTY_TRUE);
    If someone's response is helpful or correct, please mark it accordingly.

  • Selection issue with editable Spark DataGrid

    Hi everyone,
    I am evaluating the new Spark DataGrid and I'm having a very strange issue with the behavior of selection in an editable instance.
    Here is my test application: http://www.playcalliope.com/flex/DataGridSelectionIssue.html (code here: https://gist.github.com/1129160)
    And here are the steps to reproduce the issue:
    select the very first cell at the top-left corner of the grid (the one with "Gabriele");
    click on it once more, the editor appears;
    now click on the cell just to the right of it (the one with "Genta").
    You should see that editing ends as it supposed to do, but selection is placed on the third cell (the one with a 5 in it) instead on the one you clicked on. Playing a little with the grid you should see that this isn't the only case, but selection is really behaving randomly.
    I am using SDK 4.5.1.21328.
    I think this is a very basic usage case.. I can't believe this is not working properly, what am I missing?
    Thanks a lot,
    Gabriele Genta
    Message was edited to add live example

    Your running into a known bug, https://bugs.adobe.com/jira/browse/SDK-30088.
    The  bug will be fixed in the Mega release. To work around the bug you can  create a custom editor and remove the  "dataGrid.validateNow();" call in  DataGridEditor.save().
    Here's how I modified your example to workaround the bug:
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                   xmlns:s="library://ns.adobe.com/flex/spark"
                   xmlns:mx="library://ns.adobe.com/flex/mx"
                   minWidth="955" minHeight="600"
                   backgroundColor="#E7E7E7"
                   creationComplete="application1_creationCompleteHandler(event)">
        <s:layout>
            <s:HorizontalLayout horizontalAlign="center" verticalAlign="middle"/>
        </s:layout>
        <fx:Script>
            <![CDATA[
                import mx.collections.XMLListCollection;
                import mx.events.FlexEvent;
                protected function application1_creationCompleteHandler(event:FlexEvent):void
                    testGrid.dataProvider = new XMLListCollection(testData.item);
            ]]>
        </fx:Script>
        <fx:Declarations>
            <fx:XML id="testData" xmlns="">
                <items>
                    <item>
                        <id>1</id>
                        <cognome>Gabriele</cognome>
                        <nome>Genta</nome>
                        <uhm>5</uhm>
                        <bene>molto</bene>
                    </item>
                    <item>
                        <id>10</id>
                        <cognome>Pinco</cognome>
                        <nome>Pallino</nome>
                        <uhm>10</uhm>
                        <bene>poco</bene>
                    </item>
                </items>
            </fx:XML>
            <fx:Component className="MyDefaultEditor">
                <s:DefaultGridItemEditor>
                    <fx:Script>
                        <![CDATA[
                            import mx.collections.ICollectionView;
                            import mx.collections.ISort;
                            override public function save():Boolean
                                if (!validate())
                                    return false;
                                var newData:Object = value;
                                var property:String = column.dataField;
                                var data:Object = data;
                                var typeInfo:String = "";
                                for each(var variable:XML in describeType(data).variable)
                                    if (property == [email protected]())
                                        typeInfo = [email protected]();
                                        break;
                                if (typeInfo == "String")
                                    if (!(newData is String))
                                        newData = newData.toString();
                                else if (typeInfo == "uint")
                                    if (!(newData is uint))
                                        newData = uint(newData);
                                else if (typeInfo == "int")
                                    if (!(newData is int))
                                        newData = int(newData);
                                else if (typeInfo == "Number")
                                    if (!(newData is Number))
                                        newData = Number(newData);
                                else if (typeInfo == "Boolean")
                                    if (!(newData is Boolean))
                                        var strNewData:String = newData.toString();
                                        if (strNewData)
                                            newData = (strNewData.toLowerCase() == "true") ? true : false;
                                if (property && data[property] !== newData)
                                    // If the data is sorted, turn off the sort for the edited data.
                                    var sort:ISort = null;
                                    if (dataGrid.dataProvider is ICollectionView)
                                        var dataProvider:ICollectionView = ICollectionView(dataGrid.dataProvider);
                                        if (dataProvider.sort)
                                            sort = dataProvider.sort;
                                            dataProvider.sort = null;
                                    var oldData:Object = data[property];
                                    data[property] = newData;
                                    dataGrid.dataProvider.itemUpdated(data, property, oldData, newData);
                                    // Restore the sort. The data will not be sorted due to this change.
                                    if (sort)
                                        ICollectionView(dataGrid.dataProvider).sort = sort;
                                return true;
                        ]]>
                    </fx:Script>               
                </s:DefaultGridItemEditor>
            </fx:Component>
        </fx:Declarations>
        <s:DataGrid id="testGrid" width="100%" height="100%"
                    editable="true" selectionMode="singleCell"
                    itemEditor="{new ClassFactory(MyDefaultEditor)}">
            <s:columns>
                <s:ArrayList>
                    <s:GridColumn headerText="Prova" dataField="cognome"/>
                    <s:GridColumn headerText="Prova1" dataField="nome"/>
                    <s:GridColumn headerText="Prova3" dataField="uhm"/>
                    <s:GridColumn headerText="Prova4" dataField="bene"/>
                </s:ArrayList>
            </s:columns>
        </s:DataGrid>
    </s:Application>

  • Spark Datagrid Selection change Event

    starting to work with the spark datagrid.
    I want to send off a web service using the values of a row right after they get done editing the row and leave it.
    No more change event that I can see like MX and gridItemEditorSessionSaveHandler kicks on every tab between cells
    if I use event.currentTarget.selectedItem
    Selection Change gives me the new row.
    Selection Changing only kicks with mouse row changes not tabs
    Suggestions?
    I want to register the row with both mouse (on a numeric stepper) and tab(for text fields) events.
    Thanks
    Dan Pride

    Hi Dan,
    Try valueCommit event handler, but I'm not 100% sure that is triggered upon dataProvider data changes.
    Another way is to listen for changes in the dataProvider variable.

Maybe you are looking for