Double click on Datagrid cell

Hi,
I'm developing an application where I'm using a datagrid that shows some information from an xml. Every cell in the grid is of the form
<itemRenderer>
<compoment>
<Vbox>
<HBox>
<Text/> //some text goes within this block
<Text/> //some text goes within this block
<Text/> //some text goes within this block
</Hbox>
</VBox>
</component>
</itemRenderer>
I have set a function call for the datagrid on ItemDoubleClick event; and this even gets triggered only when i double click on any TEXT that is on the cell; and NOT on any part of the cell. However, I would like to have this triggered when the user clicks anywhere in the cell.
Sombody please help,
Thanks!!

Hi,
Thanks for the suggestion. Maybe I wasn't clear in explaining the issue here. Let me throw some light now, My code is somewhat like this
<mx:VBox opaqueBackground="{myxml.@data>10 ?  '0xA2FEA2' : '0xFEA2A2' }" width="100%" height="100%" verticalScrollPolicy="off">
     <mx:Box width="100%" height="100%">
          <mx:Text id="txt1" text="Available" width="100%"/>
           <mx:Text id="txt2" text="{myxml.@data}"/>
     </mx:Box>
</mx:VBox>
The output is shown in the attachment. Now whenever I double click on the text in the datagrid(highlighted in blue in the attachment) my doubleclick even is fired; but if i click anywhere in the cell(green region in the attachment) my doubleclick event is not called.
Hope this helps! Looking forward for your assistance,
Thanks again!!
Cheers

Similar Messages

  • Needs double click to edit cell in JTable

    I know this is bad design but there's no other way that I could possibly meet the requirement which is to have dynamic components. Anyhow, the requirement is to have any kind of components(e.g. TextFields, Combobox, Regular expression fields, a panel with a number of checkboxes) in a table cell in the same column. It would have been easier to do this by using the the DefaultCellEditor, with the 'panel containing a number of checkboxes' I cannot use it.
    I already have an implementation for this requirement. There was no problem with it when we used Java 1.5. But when we shifted to Java 1.6, I noticed that I need to double-click on a cell so that I can edit it. I did not notice this behavior at all with 1.5. What could have changed in 1.6?
    Below, are my (trimmed-down) codes:
    //TestComponent.java
    public class TestComponent extends JPanel{
    private int componentHeight=16;
    public TestComponent(int i){
    this.setPreferredSize(new Dimension(90, this.componentHeight));
    setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
    switch (i){
    case 0: createTextField(); break;
    case 1: createCheckBox(); break;
    case 2: createCombo(); break;
    private void createTextField(){
    String text = null;
    int textFieldMaxLength = 5;
    JTextField oText = new JTextField(textFieldMaxLength);
    // add it to this Panel:
    this.add(oText);
    // set the data:
    text = "test";
    oText.setText(text);
    // set size for this TextField:
    Dimension fieldSize = new Dimension(
    textFieldMaxLength * 13, this.componentHeight);
              oText.setPreferredSize(fieldSize);
              oText.setMinimumSize(fieldSize);
              oText.setMaximumSize(fieldSize);     
    private void createCheckBox(){
    JCheckBox chkbox = new JCheckBox();
    this.add(chkbox);
    private void createCombo(){
    JComboBox combo = new JComboBox(new String[]{"apple", "orange", "plum", "grapefruit"});
    Dimension fieldSize = new Dimension(                    5 * 13, this.componentHeight);
              combo.setPreferredSize(fieldSize);
              combo.setMinimumSize(fieldSize);
              combo.setMaximumSize(fieldSize);
    this.add(combo);
    //ComponentCellEditor.java
    public class ComponentCellEditor extends AbstractCellEditor
         implements TableCellEditor, Serializable{
    protected JComponent editorComponent = null;     
    public Component getComponent() {
    return editorComponent;
    public Object getCellEditorValue() {
    return editorComponent;
    public boolean isCellEditable(EventObject anEvent) {
    return true;
    public boolean shouldSelectCell(EventObject anEvent) {
    return true;
    public boolean stopCellEditing() {
    fireEditingStopped();
    return true;
    // Implementing the TreeCellEditor Interface
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
    this.editorComponent = (TestComponent)value;
    return editorComponent;
    //ComponentCellRenderer.java
    public class ComponentCellRenderer implements TableCellRenderer
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    TestComponent oComp = (TestComponent) value;
    if (isSelected) {
    oComp.setForeground(table.getSelectionForeground());
    oComp.setBackground(table.getSelectionBackground());
    } else {
    oComp.setForeground(table.getForeground());
    oComp.setBackground(table.getBackground());     
    return oComp;
    //TestTable.java
    public class TestTable
    public static void main(String []args){
    String columns[] = {"Text", "Value"};          
    Class types[] = {String.class, TestComponent.class};
    boolean editable[] = {false, true};
    AsrTable table = new AsrTable(new Dimension(200, 150), columns, types, editable);
    table.addRow(new Object[]{"Field1", new TestComponent(0)});
    table.addRow(new Object[]{"Field2", new TestComponent(1)});
    table.addRow(new Object[]{"Field3", new TestComponent(2)});
    table.setDefaultEditor(TestComponent.class, new ComponentCellEditor());
    table.setDefaultRenderer(TestComponent.class, new ComponentCellRenderer());
    table.setShowGrid(false);
    table.setRowHeight(20);
    table.setRowSelectionAllowed(false);
    JFrame frame = new JFrame();
    frame.addWindowListener( new WindowAdapter() {
         public void windowClosing(WindowEvent e)
         Window win = e.getWindow();
         win.setVisible(false);
         win.dispose();
         System.exit(0);
    JScrollPane pane = new JScrollPane(table);
    frame.getContentPane().add(pane);
    frame.pack();
    frame.setVisible(true);
    }

    My last post doesn't have Code Formatting.
    // TestComponent.java
    public class TestComponent extends JPanel{
         private int componentHeight=16;
         public TestComponent(int i){
              this.setPreferredSize(new Dimension(90, this.componentHeight));
              setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
              switch (i){
                   case 0: createTextField(); break;
                   case 1: createCheckBox(); break;
              case 2: createCombo(); break;
         private void createTextField(){
              String text = null;
              int textFieldMaxLength = 5;
              JTextField oText = new JTextField(textFieldMaxLength);
              // add it to this Panel:
              this.add(oText);
              // set the data:
              text = "test";
              oText.setText(text);
              // set size for this TextField:
              Dimension fieldSize = new Dimension(
                        textFieldMaxLength * 13, this.componentHeight);
              oText.setPreferredSize(fieldSize);
              oText.setMinimumSize(fieldSize);
              oText.setMaximumSize(fieldSize);
         private void createCheckBox(){
              JCheckBox chkbox = new JCheckBox();
              this.add(chkbox);
         private void createCombo(){
              JComboBox combo = new JComboBox(new String[]{"apple", "orange", "plum", "grapefruit"});
              Dimension fieldSize = new Dimension( 5 * 13, this.componentHeight);
              combo.setPreferredSize(fieldSize);
              combo.setMinimumSize(fieldSize);
              combo.setMaximumSize(fieldSize);
              this.add(combo);
    // ComponentCellEditor.java
    public class ComponentCellEditor extends AbstractCellEditor 
         implements TableCellEditor, Serializable
         protected JComponent editorComponent = null;     
         public Component getComponent() {
              return editorComponent;
         public Object getCellEditorValue() {
              return editorComponent;     
         public boolean isCellEditable(EventObject anEvent) {
              return true;
         public boolean shouldSelectCell(EventObject anEvent) {
              return true;
         public boolean stopCellEditing() {
              fireEditingStopped();
              return true;
    //  Implementing the TreeCellEditor Interface
        public Component getTableCellEditorComponent(JTable table, Object value,
              boolean isSelected, int row, int column) {
              this.editorComponent = (TestComponent)value;
              return editorComponent;
    // ComponentCellRenderer.java
    public class ComponentCellRenderer implements TableCellRenderer
         public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row,
                   int column) {
              TestComponent oComp = (TestComponent) value;
              if (isSelected) {
                   oComp.setForeground(table.getSelectionForeground());
                   oComp.setBackground(table.getSelectionBackground());
              } else {
                   oComp.setForeground(table.getForeground());
                   oComp.setBackground(table.getBackground());
              return oComp;
    // TestTable.java
    public class TestTable
         public static void main(String []args){
              String columns[] = {"Text", "Value"};          
              Class types[] = {String.class, TestComponent.class};
              boolean editable[] = {false, true};
              AsrTable table = new AsrTable(new Dimension(200, 150), columns, types, editable);
              table.addRow(new Object[]{"Field1", new TestComponent(0)});
              table.addRow(new Object[]{"Field2", new TestComponent(1)});
              table.addRow(new Object[]{"Field3", new TestComponent(2)});
              table.setDefaultEditor(TestComponent.class, new ComponentCellEditor());
              table.setDefaultRenderer(TestComponent.class, new ComponentCellRenderer());
              table.setShowGrid(false);
              table.setRowHeight(20);
              table.setRowSelectionAllowed(false);
              JFrame frame = new JFrame();
              frame.addWindowListener( new WindowAdapter() {
                   public void windowClosing(WindowEvent e)
                        Window win = e.getWindow();
                        win.setVisible(false);
                        win.dispose();
                        System.exit(0);
              JScrollPane pane = new JScrollPane(table);
              frame.getContentPane().add(pane);
              frame.pack();
              frame.setVisible(true);
    }

  • Error on double click of a cell in ALV Grid

    Hi Experts!
    I have an ALV grid displaying a report. When I doulble click in one of the cells, it gives me the error below:
    Runtime Errors         PERFORM_NOT_FOUND                                              
    Except.                CX_SY_DYN_CALL_ILLEGAL_FORM                                    
    Date and Time          09/11/2009 11:52:58                                                                               
    Short text                                                                               
    Call (PERFORM) to a non-existent routine.                                        
        Since the caller of the procedure could not have anticipated that the             
        exception would occur, the current program is terminated.                         
        The reason for the exception is:                                                  
        The program "SAPLSLVC_FULLSCREEN" is meant to execute an external PERFORM,        
        namely the routine "USER_COMMAND " of the program "ZSTORAGE_LOC_ANALYSIS ", but   
        this routine does not exist.                                                                               
    This may be due to any of the following reasons:                                                                               
    1. One of the programs "SAPLSLVC_FULLSCREEN" or "ZSTORAGE_LOC_ANALYSIS " is       
         currently being developed.                                                       
        The name "USER_COMMAND " of the called routine may be incorrect, or               
        the routine "USER_COMMAND " is not yet implemented in the program                 
         "ZSTORAGE_LOC_ANALYSIS ".                                                        
    2. If the program SAPMSSY1 is involved in the runtime error, one of               
        the function modules called via RFC is not flagged as remote-capable.             
        (see Transaction SE37  Goto -> Administration -> RFC flag)                                                                               
    3. There is an inconsistency in the system. The versions of the                   
        programs "SAPLSLVC_FULLSCREEN" and "ZSTORAGE_LOC_ANALYSIS " do not match.
    Any suggestions on how to catch this error?
    Thaks a lot!

    Solved. Commented     i_callback_user_command = 'USER_COMMAND'.

  • How? double click to edit a cell in a JTable (Custom Editor/TableModel)

    I have a JTable with a custom table model that when you click anything in the first column a custom editor appears. I would like to know how to make the custom editor appear after a double click on any cell in the first column. It can probably be done with a MouseListener but is there any easier way to do this?
    Thanks.

    this works for me.
    public class MyJcustomEditor extends DefaultCellEditor {
    public MyJcustomEditor(JTextField tField) {
    super(tField);
    setClickCountToStart(2);
    }

  • Must double click JTable cell to edit - Why?

    Hi there,
    I have a custom JTable model, which overrides the isCellEditable method and returns true for the first column. All nice, only that column now gets editable - but why do I have to double click in the cell to be able to edit in it? I've seen swing gui's where the cell gets editable on single click/focus...
    Very thankful for any help in resolving this!
    Best regard,
    AC

    Add a mouselistener to your table and in the mousePressed() method set the editing cell:
    table.editCellAt(row, column);
    table.setEditingRow(row);
    table.setEditingColumn(column);
    table.repaint();

  • When clicking on datagrid row it throws me exception - WPF C#

    Whenever I try to double click my datagrid row to edit it, I throws me a few exceptions which doesn't say anything to me. Hovever if
    I set the whole datagrid to IsReadOnly to true, I want have the problem, but I need the second and third columns editable.
    XAML
    <DataGrid x:Name="clientList" HorizontalAlignment="Left" Height="225" Margin="11,126,0,0" VerticalAlignment="Top" Width="349" IsSynchronizedWithCurrentItem="False" AutoGenerateColumns="False" HorizontalGridLinesBrush="#FFB9B9B9" VerticalGridLinesBrush="#FF8B8B8B" GridLinesVisibility="Horizontal" CellStyle="{StaticResource Body_Content_DataGrid_Centering}">
    <DataGrid.Resources>
    <LinearGradientBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" StartPoint="0,0" EndPoint="0,1" >
    <GradientStop Color="#66240000" Offset="0"/>
    <GradientStop Color="#CC240000" Offset="0.65"/>
    </LinearGradientBrush>
    </DataGrid.Resources>
    <DataGrid.Columns>
    <DataGridTextColumn Width="30" Header="Id" IsReadOnly="True" Binding="{Binding Id}"/>
    <DataGridTextColumn Width="100" Header="Company" IsReadOnly="False" Binding="{Binding Company}"/>
    <DataGridTextColumn Width="130" Header="Name, Surname" IsReadOnly="False" Binding="{Binding Name}"/>
    <DataGridTemplateColumn Header="Actions" CellTemplate="{StaticResource myTemplate}"/>
    </DataGrid.Columns>
    </DataGrid>
    C#
    clientList.Items.Add(new DataClients { Id = 1, Company = "My Company", Name = "Jane Roe"});
    Exceptions
    Exception:Thrown: "'EditItem' is not allowed for this view."(System.InvalidOperationException)
    Exception:Thrown: "The string was not recognized as a valid DateTime. There is an unknown word starting at index 0." (System.FormatException)

    You need to set the ItemsSource property of the clientList DataGrid to a collection of DataClients objects that supports editing. HashSet<DataClients> does not for example but List<DataClients> and ObservableCollection<DataClients> does.
    You could call the ToList() method on the collection that you set as the ItemsSource for the DataGrid to convert it to a List<DataClients>:
    clientList.ItemsSource = yourCollection.ToList();
    The "The string was not recognized as a valid DateTime" error message should be pretty self-explanatory. You are trying to convert a string which doesn't contain a valid date or time value to a DateTime value somewhere, perhaps in the 'myTemplate'.
    There is nothing in the DataClients class that you have posted that will cause this exception to be thrown so it is impossible for anyone to tell.
    But please only ask one question per thread and then start a new thread if you have a new question.
    Please also remember to mark helpful posts as answer to close your threads.

  • Unable to edit cells in JTable on single click of the cell.

    Hi,
    I am unable to edit a cell in JTable on single click of the cell. If I double click on the cell, I am able to edit it. Please help me.
    Thanks
    Subbu

    Thanks for all replies. Now, i am able to edit the cell on single click.

  • Problem while displaying the data when double clicked on JTable element

    Hi All,
    i have one List box( JList ) and one table (JTable). Both JTable and JList are positioned on the same Frame. I am able to drag the elements from JList to JTable and also i have added the mouse click action on both List box and JTable.
    if i double click on JList element, that will popup one dialog box.
    if i double click on JTable cell element that was dragged from JList, that will popup same dialog box which was opened earlier for JList action.
    But my problem here is:
    Suppose if i drag the four elements one by one from JList to JTable and (after four elements dragged) double clicked the first element which was dragged first that displayed the popup dialog box structure correctly but the data displayed in that was not correct. It is showing the data of recent dragged element( i.e, fourth element).
    But if i double click on JList element that is showing the correct data according to the double clicked element.
    What might be the problem here, why it was not displaying the correct data when double clicked on JTable element.
    Please help me here.
    Many thanks in advance.
    The following code is used in mouse clicked event method of JList
    private void listMouseClicked(java.awt.event.MouseEvent evt) {                                              
             if(evt.getClickCount()==2){
             AssigningResourcesUI assignResource=new AssigningResourcesUI(this,true);
             assignResource.show();
    }                AND The following code is used in mouse click enevet method of JTable.
    private void tableMouseClicked(java.awt.event.MouseEvent evt) {                                          
            if(evt.getClickCount()==2){
             int row=table.rowAtPoint(new Point(evt.getX(), evt.getY()));
             int col=table.columnAtPoint(new Point(evt.getX(), evt.getY()));
             if(row==-1||col==-1){
                 return;
              Object obj=table.getModel().getValueAt(row, col);
             if(obj==null||(obj.equals(""))){
               }else{
             AssigningResourcesUI assignResource=new AssigningResourcesUI(this,true);
             assignResource.show();
         }            Thanks & Regards,
    Maadhav....
    Edited by: maadhav on Jul 1, 2009 7:22 AM

    I doubt it is related to your problem but:
    int row=table.rowAtPoint(new Point(evt.getX(), evt.getY()));Why are you creating a new Point? Just use evt.getPoint().
    Object obj=table.getModel().getValueAt(row, col);Don't get the data through the model method, get the data through the table method:
    Object obj = table.getValueAt(...)
    This way it will work even if the table happens to be sorted.
    Instead of creating a AssigningResourcesUI object, just disply the value retrieved from the model. That way you know whether the problem is with the mouse event code or your UI class. Like Walter suggested above I"m guess the problem is with your UI class.

  • Want to place an editor only on double click

    How can I place an editor only on the Double click in that cell?
    The editors are set in someother class.
    Which method do I override to do this and how?
    Please help me with the code if possible.
    Thanks.

    In a JTable I mean

  • How not to sort datagrid column on double click

    Hello,
    I am currently building an application containing a datagrid for data representation. I've created a custom datagridheader in order to add a input text for filtering the columns (see code below).
    My goal is to hide the textinput, and then show it on a double click on the header. So i would like to know how to avoid the sort of this column each time i double click.?
    <?xml version="1.0" encoding="utf-8"?>
    <s:GridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
                        xmlns:s="library://ns.adobe.com/flex/spark"
                        xmlns:mx="library://ns.adobe.com/flex/mx" resize="onColumnResize(event)" clipAndEnableScrolling="true" doubleClick="managefilterField(event)">
        <fx:Declarations>
            <!--- The default value of the <code>sortIndicator</code> property.
            It must be an IFactory for an IVisualElement.       
            <p>This value is specified in a <code>fx:Declaration</code> block and can be overridden
            by a declaration with <code>id="defaultSortIndicator"</code>
            in an MXML subclass.</p>
            @langversion 3.0
            @playerversion Flash 10
            @playerversion AIR 2.0
            @productversion Flex 4.5
            -->
            <fx:Component id="defaultSortIndicator">
                <s:Path data="M 3.5 7.0 L 0.0 0.0 L 7.0 0.0 L 3.5 7.0" implements="spark.components.gridClasses.IGridVisualElement">
                    <fx:Script>
                        <![CDATA[
                            import spark.components.DataGrid;
                            import spark.components.Grid;
                             *  @private
                            public function prepareGridVisualElement(grid:Grid, rowIndex:int, columnIndex:int):void
                                const dataGrid:DataGrid = grid.dataGrid;
                                if (!dataGrid)
                                    return;
                                const color:uint = dataGrid.getStyle("symbolColor");
                                arrowFill1.color = color;
                                arrowFill2.color = color;
                        ]]>
                    </fx:Script>
                    <s:fill>
                        <s:RadialGradient rotation="90" focalPointRatio="1">   
                            <!--- @private -->
                            <s:GradientEntry id="arrowFill1" color="0" alpha="0.6" />
                            <!--- @private -->
                            <s:GradientEntry id="arrowFill2" color="0" alpha="0.8" />
                        </s:RadialGradient>
                    </s:fill>
                </s:Path>
            </fx:Component>
            <!--- Displays the renderer's label property, which is set to the column's <code>headerText</code>.
            It must be an instance of a <code>TextBase</code>, like <code>s:Label</code>.
            <p>This visual element is added to the <code>labelDisplayGroup</code> by the renderer's
            <code>prepare()</code> method.   Any size/location constraints specified by the labelDisplay
            define its location relative to the labelDisplayGroup.</p>
            <p>This value is specified with a <code>fx:Declaration</code> and can be overridden
            by a declaration with <code>id="labelDisplay"</code>
            in an MXML subclass.</p>
            @langversion 3.0
            @playerversion Flash 10
            @playerversion AIR 2.0
            @productversion Flex 4.5
            -->
            <s:Label id="labelDisplay"
                     verticalCenter="1" left="0" right="0" top="0" bottom="0"
                     textAlign="start"
                     fontWeight="bold"
                     verticalAlign="middle"
                     maxDisplayedLines="1"
                     showTruncationTip="true" />
        </fx:Declarations>
        <fx:Script>
            <![CDATA[
                import net.awl.ismp.console.components.misc.FilterCriteria;
                import net.awl.ismp.console.events.ColumnFilteredEvent;
                import net.awl.ismp.console.events.ColumnResizedEvent;
                import mx.events.ResizeEvent;
                import spark.components.gridClasses.IGridVisualElement;
                import mx.core.IVisualElement;
                import spark.components.DataGrid;
                import spark.components.GridColumnHeaderGroup;
                import spark.components.gridClasses.GridColumn;
                import spark.primitives.supportClasses.GraphicElement;
                // chrome color constants and variables
                private static const DEFAULT_COLOR_VALUE:uint = 0xCC;
                private static const DEFAULT_COLOR:uint = 0xCCCCCC;
                private static const DEFAULT_SYMBOL_COLOR:uint = 0x000000;
                private static var colorTransform:ColorTransform = new ColorTransform();
                 *  @private
                private function dispatchChangeEvent(type:String):void
                    if (hasEventListener(type))
                        dispatchEvent(new Event(type));                   
                protected function onColumnResize(event:ResizeEvent):void
                    dispatchEvent(new ColumnResizedEvent(ColumnResizedEvent.COLUMNRESIZED_EVT,this.width,this.column.columnInde x));
                //  maxDisplayedLines
                private var _maxDisplayedLines:int = 1;
                [Bindable("maxDisplayedLinesChanged")]
                [Inspectable(minValue="-1")]
                 *  The value of this property is used to initialize the
                 *  <code>maxDisplayedLines</code> property of this renderer's
                 *  <code>labelDisplay</code> element.
                 *  @copy spark.components.supportClasses.TextBase#maxDisplayedLines
                 *  @default 1
                 *  @langversion 3.0
                 *  @playerversion Flash 10
                 *  @playerversion AIR 1.5
                 *  @productversion Flex 4.5
                public function get maxDisplayedLines():int
                    return _maxDisplayedLines;
                override protected function stateChanged(oldState:String, newState:String, recursive:Boolean):void
                    trace("state changed from : "+oldState+" to "+newState);
                    super.stateChanged(oldState, newState, recursive);
                 *  @private
                public function set maxDisplayedLines(value:int):void
                    if (value == _maxDisplayedLines)
                        return;
                    _maxDisplayedLines = value;
                    if (labelDisplay)
                        labelDisplay.maxDisplayedLines = value;
                    invalidateSize();
                    invalidateDisplayList();
                    dispatchChangeEvent("maxDisplayedLinesChanged");
                //  sortIndicator
                private var _sortIndicator:IFactory;
                private var sortIndicatorInstance:IVisualElement;
                [Bindable("sortIndicatorChanged")]
                 *  A visual element that's displayed when the column is sorted.
                 *  <p>The sortIndicator visual element is added to the <code>sortIndicatorGroup</code>
                 *  by this renderer's <code>prepare()</code> method.  Any size/location constraints
                 *  specified by the sortIndicator define its location relative to the sortIndicatorGroup.</p>
                 *  @default null
                 *  @langversion 3.0
                 *  @playerversion Flash 10
                 *  @playerversion AIR 1.5
                 *  @productversion Flex 4.5
                public function get sortIndicator():IFactory
                    return (_sortIndicator) ? _sortIndicator : defaultSortIndicator;
                 *  @private
                public function set sortIndicator(value:IFactory):void
                    trace("setSortIndicator");
                    if (_sortIndicator == value)
                        return;
                    _sortIndicator = value;
                    if (sortIndicatorInstance)
                        sortIndicatorGroup.includeInLayout = false;
                        sortIndicatorGroup.removeElement(sortIndicatorInstance);
                        sortIndicatorInstance = null;
                    invalidateDisplayList();
                    dispatchChangeEvent("sortIndicatorChanged");
                 *  @private
                 *  Create and add the sortIndicator to the sortIndicatorGroup and the
                 *  labelDisplay into the labelDisplayGroup.
                override public function prepare(hasBeenRecycled:Boolean):void
                    trace("prepare !!");
                    super.prepare(hasBeenRecycled);
                    if (labelDisplay && labelDisplayGroup && (labelDisplay.parent != labelDisplayGroup))
                        labelDisplayGroup.removeAllElements();
                        labelDisplayGroup.addElement(labelDisplay);
                    trace(sortIndicator);
                    trace("sortIndicatorInstance : "+sortIndicatorInstance);
                    const column:GridColumn = this.column;
                    if (sortIndicator && column && column.grid && column.grid.dataGrid && column.grid.dataGrid.columnHeaderGroup)
                        const dataGrid:DataGrid = column.grid.dataGrid;
                        const columnHeaderGroup:GridColumnHeaderGroup = dataGrid.columnHeaderGroup;
                        if (columnHeaderGroup.isSortIndicatorVisible(column.columnIndex))
                            if (!sortIndicatorInstance)
                                sortIndicatorInstance = sortIndicator.newInstance();
                                sortIndicatorGroup.addElement(sortIndicatorInstance);
                                chromeColorChanged = true;
                                invalidateDisplayList();
                            // Initialize sortIndicator
                            sortIndicatorInstance.visible = true;
                            const gridVisualElement:IGridVisualElement = sortIndicatorInstance as IGridVisualElement;
                            if (gridVisualElement)
                                gridVisualElement.prepareGridVisualElement(column.grid, -1, column.columnIndex);
                            sortIndicatorGroup.includeInLayout = true;
                            sortIndicatorGroup.scaleY = (column.sortDescending) ? 1 : -1;
                        else
                            if (sortIndicatorInstance)
                                sortIndicatorGroup.removeElement(sortIndicatorInstance);
                                sortIndicatorGroup.includeInLayout = false;
                                sortIndicatorInstance = null;
                private var chromeColorChanged:Boolean = false;
                private var colorized:Boolean = false;
                 *  @private
                 *  Apply chromeColor style.
                override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
                    //trace("update display list");
                    // Apply chrome color
                    if (chromeColorChanged)
                        var chromeColor:uint = getStyle("chromeColor");
                        if (chromeColor != DEFAULT_COLOR || colorized)
                            colorTransform.redOffset = ((chromeColor & (0xFF << 16)) >> 16) - DEFAULT_COLOR_VALUE;
                            colorTransform.greenOffset = ((chromeColor & (0xFF << 8)) >> 8) - DEFAULT_COLOR_VALUE;
                            colorTransform.blueOffset = (chromeColor & 0xFF) - DEFAULT_COLOR_VALUE;
                            colorTransform.alphaMultiplier = alpha;
                            transform.colorTransform = colorTransform;
                            var exclusions:Array = [labelDisplay, sortIndicatorInstance];
                            // Apply inverse colorizing to exclusions
                            if (exclusions && exclusions.length > 0)
                                colorTransform.redOffset = -colorTransform.redOffset;
                                colorTransform.greenOffset = -colorTransform.greenOffset;
                                colorTransform.blueOffset = -colorTransform.blueOffset;
                                for (var i:int = 0; i < exclusions.length; i++)
                                    var exclusionObject:Object = exclusions[i];
                                    if (exclusionObject &&
                                        (exclusionObject is DisplayObject ||
                                            exclusionObject is GraphicElement))
                                        colorTransform.alphaMultiplier = exclusionObject.alpha;
                                        exclusionObject.transform.colorTransform = colorTransform;
                            colorized = true;
                        chromeColorChanged = false;
                    super.updateDisplayList(unscaledWidth, unscaledHeight);
                 *  @private
                override public function styleChanged(styleProp:String):void
                    var allStyles:Boolean = !styleProp || styleProp == "styleName";
                    super.styleChanged(styleProp);
                    if (allStyles || styleProp == "chromeColor")
                        chromeColorChanged = true;
                        invalidateDisplayList();
                protected function managefilterField(event:MouseEvent):void
                    trace("double click sortIndicator : "+this.sortIndicatorInstance);
                    this.filterInput.visible=!this.filterInput.visible;
                    this.filterInput.includeInLayout=this.filterInput.visible;
                    this.filterSpacer.visible=this.filterInput.visible;
                    this.filterSpacer.includeInLayout=this.filterInput.visible;
                    if(!this.filterInput.visible)
                        this.filterInput.text="";
                        dispatchEvent(new ColumnFilteredEvent(ColumnFilteredEvent.COLUMNFILTERED_EVT,new FilterCriteria(this.column.dataField,this.filterInput.text)));
                    this.filterInput.setStyle("borderColor",0xFF6319);
                    this.filterInput.setStyle("focusColor",0xFF6319);
                    //this.filterInput.setStyle(
                protected function onTextInputSelection(event:MouseEvent):void
                    event.stopImmediatePropagation();
                    this.filterInput.setStyle("borderColor",0xFF6319);
                    this.filterInput.setStyle("focusColor",0xFF6319);
                protected function onKeyUp(event:KeyboardEvent):void
                    if(event.charCode==Keyboard.ENTER)
                        stage.focus=null;
                protected function onFocusOut(event:FocusEvent):void
                    this.filterInput.setStyle("borderColor",0x00ff00);
                    this.filterInput.setStyle("focusColor",0x70B2EE);
                    dispatchEvent(new ColumnFilteredEvent(ColumnFilteredEvent.COLUMNFILTERED_EVT,new FilterCriteria(this.column.dataField,this.filterInput.text)));
            ]]>
        </fx:Script>
        <s:states>
            <s:State name="normal" />
            <s:State name="hovered" />
            <s:State name="down" />
        </s:states>     
        <!-- layer 1: shadow -->
        <!--- @private -->
        <s:Rect id="shadow" left="-1" right="-1" top="-1" bottom="-1" radiusX="2">
            <s:fill>
                <s:LinearGradient rotation="90">
                    <s:GradientEntry color="0x000000"
                                     color.down="0xFFFFFF"
                                     alpha="0.01"
                                     alpha.down="0" />
                    <s:GradientEntry color="0x000000"
                                     color.down="0xFFFFFF"
                                     alpha="0.07"
                                     alpha.down="0.5" />
                </s:LinearGradient>
            </s:fill>
        </s:Rect>
        <!-- layer 2: fill -->
        <!--- @private -->
        <s:Rect id="fill" left="0" right="0" top="0" bottom="0">
            <s:fill>
                <s:LinearGradient rotation="90">
                    <s:GradientEntry color="0xFFFFFF"
                                     color.hovered="0xBBBDBD"
                                     color.down="0xAAAAAA"
                                     alpha="0.85" />
                    <s:GradientEntry color="0xD8D8D8"
                                     color.hovered="0x9FA0A1"
                                     color.down="0x929496"
                                     alpha="0.85" />
                </s:LinearGradient>
            </s:fill>
        </s:Rect>
        <!-- layer 3: fill lowlight -->
        <!--- @private -->
        <s:Rect id="lowlight" left="0" right="0" top="0" bottom="0">
            <s:fill>
                <s:LinearGradient rotation="270">
                    <s:GradientEntry color="0x000000" ratio="0.0" alpha="0.0627" />
                    <s:GradientEntry color="0x000000" ratio="0.48" alpha="0.0099" />
                    <s:GradientEntry color="0x000000" ratio="0.48001" alpha="0" />
                </s:LinearGradient>
            </s:fill>
        </s:Rect>
        <!-- layer 4: fill highlight -->
        <!--- @private -->
        <s:Rect id="highlight" left="0" right="0" top="0" bottom="0">
            <s:fill>
                <s:LinearGradient rotation="90">
                    <s:GradientEntry color="0xFFFFFF"
                                     ratio="0.0"
                                     alpha="0.33"
                                     alpha.hovered="0.22"
                                     alpha.down="0.12"/>
                    <s:GradientEntry color="0xFFFFFF"
                                     ratio="0.48"
                                     alpha="0.33"
                                     alpha.hovered="0.22"
                                     alpha.down="0.12" />
                    <s:GradientEntry color="0xFFFFFF"
                                     ratio="0.48001"
                                     alpha="0" />
                </s:LinearGradient>
            </s:fill>
        </s:Rect> 
        <!-- layer 5: highlight stroke (all states except down) -->
        <!--- @private -->
        <s:Rect id="highlightStroke" left="0" right="0" top="0" bottom="0" excludeFrom="down">
            <s:stroke>
                <s:LinearGradientStroke rotation="90" weight="1">
                    <s:GradientEntry color="0xFFFFFF" alpha.hovered="0.22" />
                    <s:GradientEntry color="0xD8D8D8" alpha.hovered="0.22" />
                </s:LinearGradientStroke>
            </s:stroke>
        </s:Rect>
        <!-- layer 6: highlight stroke (down state only) -->
        <!--- @private -->
        <s:Rect id="hldownstroke1" left="0" right="0" top="0" bottom="0" includeIn="down">
            <s:stroke>
                <s:LinearGradientStroke rotation="90" weight="1">
                    <s:GradientEntry color="0x000000" alpha="0.25" ratio="0.0" />
                    <s:GradientEntry color="0x000000" alpha="0.25" ratio="0.001" />
                    <s:GradientEntry color="0x000000" alpha="0.07" ratio="0.0011" />
                    <s:GradientEntry color="0x000000" alpha="0.07" ratio="0.965" />
                    <s:GradientEntry color="0x000000" alpha="0.00" ratio="0.9651" />
                </s:LinearGradientStroke>
            </s:stroke>
        </s:Rect>
        <!--- @private -->
        <s:Rect id="hldownstroke2" left="1" right="1" top="1" bottom="1" includeIn="down">
            <s:stroke>
                <s:LinearGradientStroke rotation="90" weight="1">
                    <s:GradientEntry color="0x000000" alpha="0.09" ratio="0.0" />
                    <s:GradientEntry color="0x000000" alpha="0.00" ratio="0.0001" />
                </s:LinearGradientStroke>
            </s:stroke>
        </s:Rect>
        <!--<s:Rect id="fill" left="0" right="0" top="0" bottom="0">
            <s:fill>
                <s:LinearGradient rotation="90">
                    <s:GradientEntry color.normal="0xf9f9f9" color.hovered="0xfcfdfa"
                                     color.down="0xdceac2" alpha="0.85" />
                    <s:GradientEntry color.normal="0xeaeaea" color.hovered="0xdceac2"
                                     color.down="0xd2e1b5" alpha="0.85" />
                </s:LinearGradient>
            </s:fill>
        </s:Rect>-->
        <!--<s:VGroup left="7" right="7" top="5" bottom="5" gap="6" verticalAlign="middle">
            <s:TextInput width="100%" />
            <s:HGroup width="100%">
                <s:Group id="labelDisplayGroup" width="100%" />
                <s:Group id="sortIndicatorGroup" includeInLayout="false" />
            </s:HGroup>
        </s:VGroup>-->
        <s:VGroup verticalAlign="middle" left="7" top="5" right="7" bottom="5" gap="2" >
            <s:TextInput id="filterInput" width="100%" visible="false" includeInLayout="false" keyUp="onKeyUp(event)" focusOut="onFocusOut(event)" click="onTextInputSelection(event)"/>
            <s:Spacer id="filterSpacer" visible="false" includeInLayout="false" height="5" />
        <s:HGroup width="100%" height="100%" verticalAlign="middle">
            <s:Group id="labelDisplayGroup" width="100%" />
            <s:Group id="sortIndicatorGroup" includeInLayout="false" />
        </s:HGroup>
        </s:VGroup>
    </s:GridItemRenderer>

    Based on your idea, i've intercepted the click event and I use stopImmediatePropagation.
    THen i added an image to sort the column. So if the image is clicked the sort is ok.

  • How do I get the line above the tasks, which allows you to edit the cell contents, without double clicking the cell?

    As title says.
    Normally in Gantt Chart View, above the tasks there's a line which displays the contents of the cell you have selected, and allows you to edit the contents without having to double click the cell.
    In my case, this line is not there, and it is slightly hindering my work.
    So, does anyone know where I should go to re-enable this line?
    Thanks a lot!

    Hi,
    Go to file, then options, then display and check the "entry bar" option.
    http://www.manageprojectsonsharepoint.com/blog/2012/04/02/microsoft-project-quick-tip-entry-bar/
    Hope this helps.
    Guillaume Rouyre - MBA, MCP, MCTS

  • Handling ctrl+double click in a datagrid

    Hi all
    I want to have a different action if I double-click a row in a data grid, or hold down ctrl while double-clicking. If I double-click then the selectedItem property of the datagrid is populated even if I don't single-click the row first. But if hold ctrl, that selecteditem is null unless I single-click first to select the row. Does anyone know why this is so or if there is a way round it? It's ugly to have to select, hit Ctrl then double click.
    Thanks
    Martin
    Code:
    public function registerInterest():void {
            adg1.addEventListener(MouseEvent.DOUBLE_CLICK, handleGridClick);
    public function handleGridClick(event:MouseEvent):void {
        if (event.ctrlKey) { doSomething() } else { doSomethingDifferent();

    I have two dynpros:
    - In the first, in PBO I do
        CALL METHOD grid1->set_table_for_first_display
    To display the ALV
    - When I do double-clic, I raise the event handle_double_click. In the event I do a
      CALL SCREEN 2000 STARTING AT d_left_d d_top_d ENDING AT y1 y2
    to get the details. then, in the screen 2000, in the PBO, I do another
       CALL METHOD grid2->set_table_for_first_display
    to display the second ALV, the details.
    Regards.

  • Overriding double click in JTable custom cell

    I have a JTable where I reset the custom cells to become editable on a single click instead if a double using:
    ((DefaultCellEditor)table.getDefaultEditor(String.class)).setClickCountToStart(1);
    Now what I need to do is display a JPopupMenu click a cell is double clicked. This works on cells that are not editable but the problem is that the user needs the popup dialog to display info for the cells that are editable.
    I have used the basic way to implement a double click on a certain column (in this case my third column):
    public void mouseClicked(MouseEvent e){
                   if (e.getClickCount() == 2 && table.getSelectedColumn() == 2 ){
                        popupMenu.show( e.getComponent(),
    e.getX(), e.getY() );
    But when double clicking, nothing happens.
    Anyone have any idea to implement this or over-ride an editable cell?
    Thanks,
    Chris

    This still says <identifier> expect, how can I resove this please? Then you still have something wrong with your code. Since you didn't post your code how are we supposed to help?
    The proper way to ask a question is to include your demo code that trys to illustrate the problem. Something like the following:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class TableRightClick extends JFrame
         public TableRightClick()
              JTable table = new JTable(10, 5);
              table.addMouseListener( new MouseAdapter()
                   public void mousePressed(MouseEvent e)
                        if ( SwingUtilities.isRightMouseButton(e) )
    //                    if (e.isPopupTrigger())
                             JTable source = (JTable)e.getSource();
                             int row = source.rowAtPoint( e.getPoint() );
                             int column = source.columnAtPoint( e.getPoint() );
                             System.out.println(column);
                             source.changeSelection(row, column, false, false);
              table.setPreferredScrollableViewportSize(table.getPreferredSize());
              getContentPane().add( new JScrollPane(table) );
         public static void main(String[] args)
              TableRightClick frame = new TableRightClick();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.pack();
              frame.setLocationRelativeTo( null );
              frame.setVisible( true );
    }

  • Double click at a matrix cell

    hello:
       i wanna load a new form from a selected cell in a matrix using the cell double click... but i know how to do it.

    Case SAPbouiCOM.BoEventTypes.et_DOUBLE_CLICK
                        oForm = objMain.objApplication.Forms.Item(FormUID)
                        If pVal.BeforeAction = False Then
                            If pVal.ItemUID = "orad1" And pVal.ColUID = "rte" Then
                                Try
                                    oMatrix = oForm.Items.Item("orad1").Specific
                                    If pVal.Row > 0 Then
                                            Me.LoadForm(FormUID, pVal.Row)
                                        End If
                                    End If
                                Catch ex As Exception
                                    objMain.objApplication.MessageBox(ex.Message)
                                End Try
                            End If
                        End If

  • How make datagrid cell clicking not to affect the row selected?

    Hi all,
    I made SelectionUnit as FullRow. The first column, second column, and so on, which can work well for selecting row when I clicking the cells of them.
    But I want the last column to remove the affection that the whole row is selected when I click last column cell.
    how to do it? thanks.
    <DataGrid ItemsSource="{Binding itemSource}" AutoGenerateColumns="False" RowHeight="25" SelectionUnit="FullRow"

    You could set the AutogenerateColumns property to false, define all columns in the XAML markup explicitly and then specify a CellTemplate for the last column and handle its MouseLeftButtonDown event to change the SelectionUnit property of the DataGrid. Here
    is an example for you:
    <DataGrid x:Name="dg" AutoGenerateColumns="False" RowHeight="25" SelectionUnit="FullRow">
    <DataGrid.Resources>
    <Style TargetType="DataGridCell">
    <EventSetter Event="PreviewMouseLeftButtonDown" Handler="cell_MouseLeftButtonDown"/>
    </Style>
    </DataGrid.Resources>
    <DataGrid.Columns>
    <DataGridTextColumn Binding="{Binding A}"/>
    <DataGridTextColumn Binding="{Binding B}"/>
    <DataGridTextColumn Binding="{Binding C}">
    <DataGridTextColumn.CellStyle>
    <Style TargetType="DataGridCell">
    <EventSetter Event="PreviewMouseLeftButtonDown" Handler="cell_MouseLeftButtonDownLast"/>
    </Style>
    </DataGridTextColumn.CellStyle>
    </DataGridTextColumn>
    </DataGrid.Columns>
    </DataGrid>
    public partial class MainWindow : Window
    public MainWindow()
    InitializeComponent();
    List<MyItem> items = new List<MyItem>();
    items.Add(new MyItem() { A = "1", B = "1", C = "1" });
    items.Add(new MyItem() { A = "2", B = "2", C = "2" });
    dg.ItemsSource = items;
    void cell_MouseLeftButtonDownLast(object sender, MouseButtonEventArgs e)
    dg.SelectionUnit = DataGridSelectionUnit.Cell;
    void cell_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
    dg.SelectionUnit = DataGridSelectionUnit.FullRow;
    Please remember to mark all helpful posts as answer to close the thread and then please start a new thread if you have a new question.

Maybe you are looking for