Disabling multiple row selection in JTable

hi,
I have a JTable and I want to disable the multiple row selection.
I used
getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);and this working fine with ctr+clicking on a row
but if i am using shift key instead of Ctrl key multiple selection is possible....
Any idea y?and how to resolve it??
thnx
~neel

Use table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);I don't know if it differs but I use it and I don't have the problems you describe. Might be a bug in your Java version?!
Message was edited by:
pholthuizen

Similar Messages

  • Disable Multiple Row Selection in REUSE_ALV_GRID_DISPLAY

    How can I disable multiple rows from being selected in an ALV grid that is created using REUSE_ALV_GRID_DISPLAY?
    I do not see a selection mode option in the Layout for this Func Mods

    Hi John,
    You can use NO_ROWMARK of layout structrue in REUSE_ALV_GRID_DISPLAY_LVC instead. It's still SLIS type-pools in use, though.
    Check [Vijay's bottom most post|Is it possible to color a text in ALV GRID; how to use this fm.
    Regards
    Marcin
    PS: Sorry I mixed it up. I thought you want to suppress selection at all. For your request therefore SEL_MODE = 'B' of layout strcuture is what you need. Above fm still applies.
    Edited by: Marcin Pciak on Jul 30, 2009 11:16 PM

  • Multiple Row selection In JTable

    I am working with JTable and JList, I can transfer element from table to list and vise versa on clicking on button, my problem is that when i transferred element to either of them that should be selected. i can also transfer multiple item at time and doing sorting with table if i am adding element of 1st row and last row of table, both the rows should be selected.
    Any thoughts!!!!!!!!!!!
    ThnX
    Prashant_SDN

    Thnx for response and selection in list is done sucessfully.
    I have one additional query, I am transfering element from list to table and did use sorting so rows did not get added after existing row of table but added as per sorting.
    so how do i get the index of newly added row after sorting.
    Any thoughts!!!!

  • ALV Grid multiple row selection, disabling some

    Does anyone know if it is possible to have an ALV grid with multiple row selection allowed but for some rows the row selection is disabled?
    Kind regards,
    John.

    Hi John,
    You can add a check box and select multiple rows. I am using the same technique. I have used OO.
    a) Use Even handler "Double Click"
    b)Using "SELECT_ALL_ENTRIES  CHANGING PT_OUTTAB TYPE STANDARD TABLE" and I am sorting based Check box selection.
    Need more help please let me know. I will send you the code.
    Lanka
    Message was edited by: Lanka Murthy

  • Delete multiple rows in a JTable ADF Swing.

    hi guys,
    Would anyone know tell me how do I delete multiple rows in a JTable ADF Swing?
    JDeveloper.

    Hi,
    I would configure the table for multi row selection. Then get the selected row index, access the iterator in the PageDef file (through the panelBinding reference you have in ADF Swing) and then iterate over the selected row indexes, make an index to become the current row and call remove() on it
    Frank

  • Multiple row select for table not working..

    Hi Experts,
    I have a table in ABAP Web Dynpro where I have enabled the multiple row select functionality. I can select all and deselect all. I can also select a block of adjacent rows of table by choosing first and last by pressing Shift key.
    But I am not able to select multiple individual records for that table.
    I tried the same thing in different system and it works fine there.
    Please let me know if we are missing some standard plugin or we need to enable this in some settings.
    System where the issue is:
    SAP_APPL: release 600, level 18
    SAP_BASIS: Release 700, level 22
    System where it is working fine:
    SAP_APPL: release 604, level 8
    SAP_BASIS: release 701, level 8
    Regards,
    Anand Kolte

    Hi
    Press CTRL key and Select records, you can select multiple records, continuously or randomly your desired selection.
    Cheers,
    Kris.

  • ADF multiple row selection using checkbox

    One of the basic feature missing in ADF 11g is multiple row selection using checkbox (ADF supports multiple row selection by CTRL+CLICK) and business users doesn't like the idea of CTRL+CLICK especially when the volume of click is more. Our requirement is to show the records as selected, on click of checkbox. We implemented multiple row selection by giving a checkbox and on submission, iterate all the rows and filter only selected rows for further processing. The approach works fine,but it is very slow when the volume of data is more, say 10 thousand rows. For 4 thousand records, iterating everything takes more than 200 secs !
    Had the multiple row selection been the ADF standard way using CTRL+CLICK, and retrieving the selected rows using method theTable.getSelectedRowKeys() works much faster (completes in millisecs for 4 thousand records). Somehow ADF fetches the selected records much faster this way. Our requirement is on click of the checkbox, the ADF should select the records ( the same way it is doing CTRL+CLICK) and all such selected rows should be retrievable using the ADF method theTable.getSelectedRowKeys()
    Is there any way it can be done?
    Regards,
    Antony.

    Hi All,
    We have implemented the select and select all using check-box and it is working fine. Issue here is the performance is too slow
    Assume SelectValue is the VO coulmn for the checkbox to select the values. To filter out the selected rows, we use the following line
    Row[] pidRows = pidView.getFilteredRows("SelectValue", Boolean.TRUE);
    it is very taking more than 2 minutes if the total number of rows are *4 thousands* and only if 2 rows are selected.
    Whereas with the CTRL+CLICK standard approach, ADF has a built in API theTable.getSelectedRowKeys(); to get only the selected rows, and the built in API takes only few milliseconds to get the selected rows. Users are not agreeing to the CTRL+CLICK approach as it is not user friendly. Suggest if there is a way to make the select box to make it work the same way as CTRL+CLICK.
    code snippet to do the standard way :
    RowKeySet sk = theTable.getSelectedRowKeys();
    _logger.info("row count of select "+sk.getSize());;+
    Iterator selection =sk.iterator();
    EmpVORowImpl empRow = null;
    +while (selection.hasNext()) {+
    Object rowKey = selection.next();
    theTable.setRowKey(rowKey);
    rowdata = (JUCtrlHierNodeBinding)theTable.getRowData();
    empRow  = (EmpVORowImpl)rowdata.getRow();
    _logger.info("Emp # "+empRow.getEmpno() +" Emp Name : "+empRow.getEname() +" Is selected ? "+empRow.getisChecked());+
    +}+

  • Multiple row selection in ADF Table using addition column with checkbox

    I am using ADF table(Jdeveloper11g) and i want to selecte multiple rows it may be more than one OR all rows.
    For that i added one Column to the table with Header Delete and checkbox
    <af:table....
    <af:column sortProperty="Delete" headerText="Delete" width="100"
    sortable="false">
    <af:selectBooleanCheckbox label="#{row.favoriteId}"
    valueChangeListener="#{Mybean.onCheck}"
    id="checkbox" autoSubmit="true">
    </af:selectBooleanCheckbox>
    </af:column>
    </af:table>
    backing bean:Here i added code to get Value of one column with id favoriteId and use an arrayList(listForDelete) to monitor the state of the checkboxes
    public void onCheck(ValueChangeEvent valueChangeEvent) {
    BindingContainer bindings = getBindings();
    DCBindingContainer dcBindings =
    (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    DCIteratorBinding iterBind =
    (DCIteratorBinding)bindings.get("getUserFavoritesByUserIDIterator");
    if (iterBind != null && iterBind.getCurrentRow() != null) {
    RichSelectBooleanCheckbox ch = (RichSelectBooleanCheckbox)valueChangeEvent.getSource();
    if (!ch.isSelected()) {
    Long issueId = (Long)iterBind.getCurrentRow().getAttribute("favoriteId");
    listForDelete.add(issueId);
    else
    Long issueId = (Long)iterBind.getCurrentRow().getAttribute("favoriteId");
    listForDelete.remove(issueId);
    Problem is that when i select single row checkBox, onCheck() method of backing bean gets called multiple times(equals to the number of rows)
    I think this is beacuse of <af:selectBooleanCheckbox id is same that is "checkbox" but i am not sure.Even i tried to assign some unique id but no any success in assigning Id with value Expression.
    I also find related post
    Re: ADF Table Multiple row selection by Managed Bean
    but that is related to Select All rows or Deselect all rows from table.
    From the simillar post i follow the steps given by Frank.but problem with below step
    ->have an af:clientAttribute assigned to the checkbox with the following EL #{row.key} ,here I added <af:clientAttribute name="#{row.key}"></af:clientAttribute> and i am getting error
    Error(64,37):  Static attribute must be a String literal, its illegal to specify an expression.
    Please let me know if any one had already implemented same test case.
    Thanks for all help
    Jaydeep
    Edited by: JaydeepJ on Aug 7, 2009 4:42 AM

    just to update after the rollback is called in the cancel button i wrote following code which does not change the row focus to the first row
    DCBindingContainer bc =
    (DCBindingContainer)BindingUtils.getBindingContext().getCurrentBindingsEntry();
    DCIteratorBinding profItr =
    bc.findIteratorBinding("ProfileSearchInstIterator");
    Row cRow = profItr.getRowAtRangeIndex(0);
    if(cRow != null){
    System.out.println("Current row is not null so fixed ");
    profItr.setCurrentRowIndexInRange(0);
    RowKeySetImpl rks = new RowKeySetImpl();
    ArrayList keyList = new ArrayList();
    keyList.add(cRow.getKey());
    rks.add(keyList);
    profileTable.setSelectedRowKeys(rks);
    AdfFacesContext.getCurrentInstance().addPartialTarget(profileTable);
    }

  • Multiple row selection for table element

    Hi,
    I have a requirement where I require to select multiple rows from a table element in a WD for abap application.
    I have defined a node with cardinality and selection set to 1..n.
    The contex node contains 4 fields : emp_name, pernr, manager and position.
    The attributes of the table element for selectionmode is set to 'multi' and 'selectionchangebehaviour' is set to 'auto'.
    I have defined an action on the 'onleadselection' event.
    The code in this method also includes the statement 'lo_el_team_view->set_selected( EXPORTING flag = abap_true ).' 
    When I execute the application only 1 row is highlighted at any one time when I select it. You can select multiple rows by holding down the 'ctrl' key but I want to avoid having to do this. Is there anything I have missed out causing multiple row selections not to be all highlighted.
    Thanks in advance for any assistance.

    Hi raj,
    you can try the following code in the 'onleadselect' event of the table,
    create one attribute ' Flag'  of type WDY_BOOLEAN under the node which has been binded to the table.
    DATA lo_nd_node_tab1 TYPE REF TO if_wd_context_node.
      DATA lo_el_node_tab1 TYPE REF TO if_wd_context_element.
      DATA  lo_elements TYPE wdr_context_element_set.
      DATA  lo_ele_select_new TYPE REF TO if_wd_context_element.
      DATA lv_deselect TYPE wdy_boolean.
      DATA lv_flag TYPE wdy_boolean.
      DATA lv_select TYPE wdy_boolean.
      DATA lv_index TYPE i VALUE 0.
      lo_nd_node_tab1 = wd_context->get_child_node( name = wd_this->wdctx_node_tab1 ).
    get the current selected element
      lo_ele_select_new = wdevent->get_context_element( name = 'NEW_ROW_ELEMENT' ).
      CHECK lo_ele_select_new IS NOT INITIAL.
    check whether it has been selected or not
      CALL METHOD lo_ele_select_new->is_selected
        RECEIVING
          flag = lv_select.
      lo_ele_select_new->get_attribute( EXPORTING name = 'FLAG' IMPORTING value = lv_deselect ).
    check whether element has been previously selected or not,if not, set the flag to select it
    IF lv_select IS NOT INITIAL AND lv_deselect IS INITIAL.
        lo_ele_select_new->set_attribute( name = 'FLAG' value = 'X' ).
    if selected currently and previously then set the flag as false,in order to delect it
      ELSEIF lv_select IS NOT INITIAL AND lv_deselect IS NOT INITIAL..
        lo_ele_select_new->set_attribute( name = 'FLAG' value = ' ' ).
      ENDIF.
      CALL METHOD lo_nd_node_tab1->get_elements
        RECEIVING
          set = lo_elements.
    according to the falg, select and delect the elements
    LOOP AT lo_elements INTO lo_el_node_tab1.
        lo_el_node_tab1->get_attribute( EXPORTING name = 'FLAG' IMPORTING value = lv_flag ).
        IF lv_flag = 'X'.
          lo_el_node_tab1->set_selected( abap_true ).
          lo_nd_node_tab1->set_lead_selection_index( lv_index ).  * this statement deselects the lead selection index*
        ELSE.
          lo_el_node_tab1->set_selected( abap_false ).
          lo_nd_node_tab1->set_lead_selection_index( lv_index ).
        ENDIF.
      ENDLOOP.
    I hope this resolves your problem.
    Thanks,
    krishna

  • Multiple row selection capability in the table

    Hi
    I have a group with table layout style and I want to set the rowSelection property of the generated table to "multiple" but it seems that there is no way to do that from JHs unless using the group as LOV, which is not desired for me. Here is the code which sets this property in tableGroup.vm :
    #if (! ($JHS.current.group.useAsLov && $JHS.current.group.multiSelect))
    selectionListener="#{#BINDINGS_TABLE().collectionModel.makeCurrent}"
    rowSelection="single"
    #if( ! $JHS.current.group.useAsLov )
    selectedRowKeys="#{#TABLE_BEAN().selectedRow}"
    #end
    #else
    rowSelection="multiple"
    selectedRowKeys="#{#LOV_PAGE_BEAN().selectedRowKeySet}"
    selectionListener="#{#LOV_PAGE_BEAN().selectionListener}"
    #end
    Is there any reason to not allowing to have multiple row selection capability in the table when it is not in LOV mode?
    Thanks
    Ferez

    Ferez,
    No, but if you want to have multiple selection, there is typical a custom action you want to apply to the selected rows, which cannot be defined in the Jheadstart Application Definition editor.
    However, it is perfectly fine to use a custom tableGroup.vm template and enable multi-selection.
    Steven Davelaar,
    JHeadstart team.

  • Handle multiple rows selection on Matrix

    Hi all,
    i'd like to know if someone could help me with multiple selections on matrix via shift + left mouse button on a matrix.
    I got a matrix with one column containing a checkbox for selection. The matrix, on a UDO Form, is defined as auto selecting, so multiple selection of rows is allowed.
    I want to add the rows selected by the checkbox (using shift + left mouse button on the selection start and selection end) column to the matrix selected rows collection.
    Is there any chance to catch an event handling this situation?
    I can add the rows in the matrix selected rows collection clicking the checkboxes one by one, but when i use the multiple selection i can't get any event handling this.
    I know i couldn't use the checkbox for the selection and use instead the native function of sap b1 matrix., but this way is faster (and more clear, because you see the check when a row is selected) when you have multiple rows selected one by one
    I hope i've been clear enough, and hope somene can give me an hint.
    Thanks in advance.

    Hi Cesidio,
    if I understand you correctly you want to select one row than shift+mouseclick some rows lower and the result should be, that all rows are selected ?
    You can achieve this by catching the itempressed event and querying pVal.Modifiers.
    This is an example for Grid :
    private void Grid0_PressedAfter(object sboObject, SAPbouiCOM.SBOItemEventArg pVal)
                if (pVal.Modifiers == SAPbouiCOM.BoModifiersEnum.mt_SHIFT)
                    int lastRowSelected =Grid0.Rows.SelectedRows.Item(Grid0.Rows.SelectedRows.Count-1,SAPbouiCOM.BoOrderType.ot_RowOrder);
                    if (lastRowSelected < pVal.Row)
                        for (int i = pVal.Row; i > lastRowSelected; i--)
                            Grid0.Rows.SelectedRows.Add(i);
    regards,
    Maik

  • Multiple rows selection handling in Tableview

    Hi guys,
    ..Good morning ..
    I have developed one page for displaying Employees(pernr and Ename) under CEO/VP/Managers using <b>TableView</b>.
    Here i have some difficulties.
    <b>1.</b> I managed to show Multiple row selection menu
       (Selectall/deselectall) right upper corner of
       Tableview. but i can also select multiple rows not all
       at a time .So in this case ,those selected employees
       Overtime amount i want to show in the next page.here
       my question is How do i capture selected rows(not all
       at a time).
       I am using this code ..
    <htmlb:tableView id     = "tvX"
             headerText     = "Employee List"
              headerVisible = "true"
              idth          = "30%"
        selectedRowKeyTable = "<%= selectedRowKeyTable %>"
        onRowSelection      = "MyEventRowSelection"
        sort                = "server"
        keepSelectedRow     = "TRUE"
        selectionMode       = "MULTISELECT"
        table               = "<%= i_emp_1 %>" >
    <htmlb:tableViewColumns>
    <htmlb:tableViewColumn columnName          = "pernr"
                           width               = "10"
                           sort                = "server"
                           horizontalAlignment = "center"
                           title               = "Emp No"
                           type                = "TEXT" >
    </htmlb:tableViewColumn>
    <htmlb:tableViewColumn columnName          = "ename"
                           width               = "40"
                           sort                = "server"
                           horizontalAlignment = "center"
                           title               = "Emp Name"
                           type                = "TEXT" >
    </htmlb:tableViewColumn>
    </htmlb:tableViewColumns>
    </htmlb:tableView>
    <b>2</b>. How to send one Itab data from one page to
       another page.Presently i am using EXPORT/IMPORT
       statements.Is this right way or any other method is
       there for?. 
    Could you please look in to this ..
    <b>Best regards,
    Venkat.O</b>

    Hi Venkataiah,
    See page <b>TableViewMultiSelect.bsp</b> in BSP application SBSPEXT_TABLE.
    There is an attribute <b>selectedRowIndexTable</b> in tableView element. you have to assign a table of type INT4_TABLE, and you can fill this table by table_event->PREVSELECTEDROWINDEXTABLE in OnInputProcessing event. For more details see the above mentioned bsp application.
    To Export/Import is ok,  you can use server-side cookies also, But best way is using model binding. Learn MVC for that.
    Hope it solves your problem.
    Regards,
    Narnder Hartala

  • Select multiple rows on a JTable

    Hi!
    Given: JTable, multiple selection allowed
    Wanted: a way to be able to set multiple non-continuous rows selected
    eg. on a JTable with 5 rows,
    I want to set rows 1, 3 and 5 selected
    Anyone?
    Stoffel.

    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTE
    VAL_SELECTION);
    select rows using <ctrl> and/or <shift>Or if you want to set programaticly use this methods, see the api
    for explanation.
    table.changeSelecton(int row, int column, boolean toogle, boolean extend);
    table.addRowSelection(int index0, int index1);
    table.addColumnSelectionInterval(int index0, int index1)
    ...

  • JClient - Strange Behaviour when using multiple-row-selection

    Hi!
    In my application a problem occures whenever I want to select multple rows in a JTable...
    I am using a JTable bound to a ViewObject which displays quite a lot of rows. For further processing I need to select more than one row. So I changed the code the following way:
    table.setModel(JUTableBinding.createAttributeListBinding(panelBinding, table, "SomeView", null, "SomeViewIter", new String[] {"FirstAttribute", "SecondAttribute"}));
    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    Basically there are 2 problems:
    Whenever I want to select several rows or intervals by dragging the mouse or by using cursers, older selections disappear.
    When I select rows and then use the scrollbar, all selections but one disappear.
    Is there something wrong in my implementation or is this another bug? That's one of those little things, that make life of developers and end-users hard.
    Any suggestions? Thanks a lot!

    Hi!
    In my application a problem occures whenever I want to select multple rows in a JTable...
    I am using a JTable bound to a ViewObject which displays quite a lot of rows. For further processing I need to select more than one row. So I changed the code the following way:
    table.setModel(JUTableBinding.createAttributeListBinding(panelBinding, table, "SomeView", null, "SomeViewIter", new String[] {"FirstAttribute", "SecondAttribute"}));
    table.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);JUTableBinding only works with Single-selection model as it needs to track currency based on the current selection.
    You'd have to implement a custom Table-model that wraps the built-in table model (quite like what's done in the 'table sorting example' at
    http://otn.oracle.com/sample_code/products/jdev/jclient/jclient_table_sorting_sample.html
    Then you may implement multiple selection and fake single selection model (last selected row perhaps) to the JUTableBinding's tableModel.
    Basically there are 2 problems:
    Whenever I want to select several rows or intervals by dragging the mouse or by using cursers, older selections disappear.
    When I select rows and then use the scrollbar, all selections but one disappear.
    Is there something wrong in my implementation or is this another bug? That's one of those little things, that make life of developers and end-users hard.
    Any suggestions? Thanks a lot!

  • Is it possible to enable/disable table row selection?

    I have a situation where a user can add rows to a "selection" table with a value that is used to perform a query to get a collection of objects associated with that value. Once those objects are available, a second "results" table will be populated with the row(s) returned. When the value is entered in the selection table, a web service call is made to perform the query and return the results. This may take a few moments and I am displaying an indeterminate progress indicator for the selection table row involved to indicate that the data is not yet available - the progress indicator is included as a column in the row; each row has its own indicator. Once the results are received the indicator is hidden to indicate the query for that row has completed. The user may enter as many rows in the selection table as they wish so there is a distinct possibility of multiple queries being executed at a given time. I have also attached a row selection listener to the selection table such that when a given row is selected, the results table will display the corresponding associated row(s).
    What I'd like to be able to do is somehow temporarily disable the selection of any row that has a query in progress, while leaving other rows whose queries have completed be selectable. Once the query completes, the row can then become selectable, thus allowing for the results to be loaded and displayed in the results table. The way it works right now, if the row is selected while the query is still in progress, nothing is displayed (obviously), but then the row has to be re-selected after the query has completed to see the results. This is a viable (though undesirable) solution/workaround if there is at least one other row in the table. However, if the row is the only row in the table and has been selected, it cannot be re-selected (there's no other row to select to allow for re-selection). To boil it down, what I'd like to do is prevent the selection of the row until the query for that row is complete.
    After perusing the JavaFX 2.2 API, I'm not seeing any obvious way to achieve this effect. If anyone has any solutions, suggestions, etc. on how this could be done I'd appreciate it greatly.

    Here's an [url https://github.com/james-d/Conditionally-selectable-table]example. As predicted, keyboard navigation fails if the keyboard presses would result in an unselectable item being selected using the default selection model. The best workaround I can see for this is to register event filters for the appropriate keyboard strokes, as in the previously referenced thread.
    Update: That code won't run in the current (ea b90) release of JavaFX 8.0, and probably a few recent releases; it will however run in the final release (and it runs in JDK 7). See [url https://javafx-jira.kenai.com/browse/RT-30593]RT-30593
    Edited by: James_D on May 22, 2013 7:51 PM

Maybe you are looking for

  • Shuffle G2 not recognised by computer or iTunes

    Has anyone been able to solve this problem yet? If so please tell me, I am so frustrated with this. Device manager refers to the shuffle as an 'Unknown Device' My compter does not register it (the folder named my compter that is) and neither does iTu

  • FF 5.0 wont show attachment preview in hotmail

    update to 5.0 now when i open email with attachment the preview bar at top just says loading...nothing happens. normally shows preview of pic or vid. works in IE 8

  • ITunes keeps trying to access Apple Store

    My iTunes has suddenly stopped simply playing tunes because it keeps bringing up a message saying it can't access the Store. (I don't have the internet connected because I'm only on dial-up during the day). I don't want my computer automatically tryi

  • HELP! My phone shutoff by itself and won't power back on!

    My iPhone was fully charged and had been working fine all day. I just went to check emails on it and it is completely black. I tried to power it back on and nothing, not even when plugged into the charger. Why would this happen and how can I get it b

  • Two profiles on my account - One not mine

    Hi  I havent used Skype for a while but recently upgraded to Win8 so thought Id try the app. I had to reset my password as I must have forgot it, however when I received the email it was address to an Indian name and not mine! I then clicked the link