Use spacebar to check/uncheck a checkbox in a datagrid.

I have a DataGrid that has checkbox in the first column. The user wants to be able to check/uncheck the checkbox when he selects a row, by mouse or up and down keys, and hits the spacebar. Currently the spacebar functions if the last thing that the use has clicked on is the Checkbox. If the user clicks in the cell where the checkbox in located(not the checkbox itself), the spacebar won't do anything.
<mx:TabNavigator>
     <mx:VBox>
          <ms:datagrid id="lgGrid" dataProvider="{this.lData}">
               <mx:columns>
                    <mx:Array>
                         <mx:DataGridColumn dataField="vis" id="dfID" sortable="false">
                              <mx:itemRenderer>
                                   <mx:Component>
                                        <mx:CheckBox click="data.vis = !data.vis"  paddingLeft="4"/>
                                   </mx:Component>
                              </mx:itemRenderer>
                          </mx:DataGridColumn>
                          <mx:DataGridColumn dataField="name"/>
                    </mx:Array>
               </mx:columns>
          </ms:datagrid
   </mx:VBox>
</mx:TabNavigator>

Your TableModel has to indicate that the column is editable. Your TableModel also has to implement setValueAt() so that when the user changes the value, it updates the data.
The table will know to use it's own boolean renderer/editor for that column because it knows what to do when a column returns a Boolean.

Similar Messages

  • Unable to check / uncheck a checkbox in a JTable...

    Hi all,
    I know that a lot of people have asked this question before but I am unable to find a solution even after going all the messages. My issue is:
    My initial rendering of the checkboxes inside the table works ok. I am using a TableCellRenderer and my input to determine the "checked/unchecked" is string like "true" or "false" and not boolean values. But I am unable to do check / uncheck any of the checkboxes.
    I would really appreciate any pointers.
    Thanks in advance.
    Below is my code snippet:
    public Component getTableCellRendererComponent(JTable table_,
    Object value_, boolean isSelected_, boolean hasFocus_, int rowIndex_,
    int colIndex_)
    Component component = super.getTableCellRendererComponent(table_,
    value_, isSelected_, hasFocus_, rowIndex_, colIndex_);
    indicator = table_.getColumnModel().getColumnIndex("IND");      
    if (indicator == colIndex_)
         if (value_.equals("true")){
              component = new JCheckBox("", true);           
         } else {
              component = new JCheckBox("", false);           
         return component;
    }

    Your TableModel has to indicate that the column is editable. Your TableModel also has to implement setValueAt() so that when the user changes the value, it updates the data.
    The table will know to use it's own boolean renderer/editor for that column because it knows what to do when a column returns a Boolean.

  • Using APEX_ITEM.MULTI_ROW_UPDATE along with APEX_ITEM.CHECKBOX

    Hi,
    I am stuck working with APEX_ITEM.MULTI_ROW_UPDATE process for the past 2 days.
    I don't see any working examples in forum as well to update APEX_ITEM.CHECKBOX values using the APEX_ITEM.MULTI_ROW_UPDATE process.
    My updateable query is as below :
    select APEX_ITEM.HIDDEN(1,INST_ID) ||
           APEX_ITEM.TEXT(2,INST_NME,20,200) AS INST_NME,
           APEX_ITEM.TEXT(3,INST_CTY_TXT,10,50) AS INST_CTY_TXT,
           APEX_ITEM.SELECT_LIST_FROM_LOV(4,ST_CDE,'STATES_LOV',NULL,'YES','ZZ','~ Select ~') AS ST_CDE,
           APEX_ITEM.MD5_CHECKSUM( INST_NME,
                                   INST_CTY_TXT,
                                   ST_CDE,
                                   LGE_IND
                        ) || APEX_ITEM.CHECKBOX(5,LGE_IND,NULL,-1) AS LGE_IND
    from  TESTNote: I am using -1 for checked value of checkbox.
    My update process is
      BEGIN
        APEX_ITEM.MULTI_ROW_UPDATE('#OWNER#:TEST:INST_ID,1:,|INST_NME,2:INST_CTY_TXT,3:ST_CDE,4:LGE_IND,5');
      END;Now when I update any field and Save the changes I get the error below :
      ORA-20001: Error in MRU: row= 1, ORA-01403: no data found, update If I use textbox instead of checkbox and write the code as below it works perfect.
    select APEX_ITEM.HIDDEN(1,INST_ID) ||
           APEX_ITEM.TEXT(2,INST_NME,20,200) AS INST_NME,
           APEX_ITEM.TEXT(3,INST_CTY_TXT,10,50) AS INST_CTY_TXT,
           APEX_ITEM.SELECT_LIST_FROM_LOV(4,ST_CDE,'STATES_LOV',NULL,'YES','ZZ','~ Select ~') AS ST_CDE,
           APEX_ITEM.MD5_CHECKSUM( INST_NME,
                                   INST_CTY_TXT,
                                   ST_CDE,
                                   LGE_IND
                        ) || APEX_ITEM.TEXT(5,LGE_IND,5,10) AS LGE_IND
    from  TEST;
      BEGIN
        APEX_ITEM.MULTI_ROW_UPDATE('#OWNER#:TEST:INST_ID,1:,|INST_NME,2:INST_CTY_TXT,3:ST_CDE,4:LGE_IND,5');
      END;If anyone see what is wrong that I am doing please help me out here.
    Your help is greatly appreciated.
    Thanks,
    Raj.

    Hi,
    You should concatenate your HIDDEN item(s) to the front of the next displayed item - that way you do not get a column in the tabular form that you have to hide (hiding the column could have the effect of stopping the item from being submitted with the page)
    Secondly, all the fields should be based on actual column names so that the MD5_CHECKSUM that reference these.
    DUAL doesn't provide column names directly but you may be able to do something like:
    SELECT
    APEX_ITEM.HIDDEN(1, ID) || APEX_ITEM.TEXT(2, PRODUCT_NAME, 60, 60) product_name,
    APEX_ITEM.SELECT_LIST_FROM_LOV(3,CATEGORY,'CATEGORY',NULL,'YES',NULL,'-Select Category-',null,null,'NO') CATEGORY,
    APEX_ITEM.MD5_CHECKSUM(PRODUCT_NAME,CATEGORY)
    FROM (SELECT NULL ID, NULL PRODUCT_NAME, NULL CATEGORY FROM DUAL)Alternatively, you could create an empty row from the actual table:
    SELECT
    APEX_ITEM.HIDDEN(1, ID) || APEX_ITEM.TEXT(2, PRODUCT_NAME, 60, 60) product_name,
    APEX_ITEM.SELECT_LIST_FROM_LOV(3,CATEGORY,'CATEGORY',NULL,'YES',NULL,'-Select Category-',null,null,'NO') CATEGORY,
    APEX_ITEM.MD5_CHECKSUM(PRODUCT_NAME,CATEGORY)
    FROM (SELECT NULL ID, NULL PRODUCT_NAME, NULL CATEGORY FROM EBA_ASSET_ASSETS WHERE ROWNUM = 1)Then Scott's code should work:
    BEGIN
    APEX_ITEM.MULTI_ROW_UPDATE('#OWNER#:EBA_ASSET_ASSETS:ID,1:|ASSET_NAME,2:CATEGORY_ID,3');
    END;Note that you have to include the : before the | as this function assumes that there are two primary keys - as the table only has one, the second one is empty, but must be included.
    Andy

  • Using Javascript To UnCheck A Checkbox

    Hi,
    I have a select list with two options in. When one of them is selected I have two checkboxes that I want hiding and setting to unselected. I can hide and show them fine using *$x_HideItemRow* and *$x_ShowItemRow*, but when I hide them I want the setting as unselected.
    Have tried using html_GetElement(pThat).checked = false; but when the items are displayed again they are still displayed as selected.
    Can anyone show me how to uncheck a checkbox using javascript?
    Cheers
    Simon

    Simon,
    Use firebug in firefox to see what's happening. The name of your item is applied to an HTML fieldset element that contains the actual inputs of type checkbox. Each of those has a name based on the item name with "_X" on the end as in PXX_ITEM_NAME_0.
    You'll need to select the one you want to check/uncheck directly by adding the underscore and the number. Also, you can use $x over html_GetElement (just shorter).
    Regards,
    Dan
    http://danielmcghan.us
    http://sourceforge.net/projects/tapigen

  • Check whether the checkbox in a form is checked or not using javascript

    when we click a check box (TBD) it should set the value of a field to a default value '1234'. If we uncheck the checkbox, it should set the field as Null.
    I have defined the checkbox as STATIC2:;1234 in form.
    I used the onClick event on the checkbox and called a function to update the column.
    Inside the function i am checking whether the check box is checked using
    if (document.getElementById('P4_TBD').checked=true)
    document.getElementById('P4_COL1).value='1234';
    else
    document.getElementById('P4_COL1).value=''; /* or $s("P4_COL1", "");
    it works only when check box is checked. If check box is unchecked it is not setting the field as Null.
    I checked document.getElementById('P4_TBD').checked=false instead of else clause. it is not working.
    Please help me on this issue.
    Thanks,
    Ravi

    When you are using checkboxes or option button, the ID for your button is using an index. If you create a group of 3 checkboxes with the ID = "MY_CHECKBOXES", APEX will create the following IDs for each of your options : MY_CHECKBOXES_0, MY_CHECKBOXES_1 and MY_CHECKBOXES_2. If you want to test if the first checkboxe is checked, you'll use document.getElementById('MY_CHECKBOXES_0').checked.
    I didn't test for a lone checkbox, but I expect your checkbox to be "TDB_0" not "TDB" who is the frame around your checkbox group.

  • How to uncheck a checkbox using Screen Variants?

    Hi Masters!
    Anybody knows how to uncheck a checkbox that is already checked by default?
    I'm trying to do this using screen variants. I uncheck the checkbox and save the value (I also tried filling other values there like 'a', space, etc. and it didn't work), but at runtime it always shows the checkbox checked.
    At the same transaction there is a unchecked checkbox by default witch I can check it with a screen variant, but somehow I can't do the other way around...
    Any suggestions?
    Many thanks in advance,
    José Omar

    I checked the code and found something interesting. The
    variable I'm trying to uncheck is GV_WITH_CONTACT_PERSON.
    It's declaration:
    DATA: GV_WITH_CONTACT_PERSON TYPE XFELD VALUE 'X'.
    At the initialization of the program (at the first screen module):
    PROCESS BEFORE OUTPUT.
    MODULE INITIAL_STATE.
    And inside the MODULE INITIAL_STATE there is also:
    MOVE 'X' TO GV_WITH_CONTACT_PERSON.
    So there are places in the code that the checkbox is checked.
    Now we get another problem. I don't now when the values set at a screen variant are inserted in the screen. Is it possible that the code itself is overwriting the value set with a screen variant? Or is this not possible at this point in the code?
    Many Thanks,
    José Omar

  • Struts : checkbox status is unchanged if i use back button and uncheck it.

    hi
    I have a couple of checkboxes in a jsp page used in struts framework. I am using DynaValidatorForm as form bean with session scope, so it means the properties are mapped only in the struts-config.xml. the checkboxes' property names are checkbox1 and checkbox2.
    now the in the action class, i do:
    public ActionForward execute(ActionMapping mapping,
                ActionForm form,
                HttpServletRequest request,
                HttpServletResponse response)
         throws Exception {
              DynaValidatorForm dynaform = (DynaValidatorForm)form;
                                              System.out.println("1st checkbox value:"+ dynaform.get("checkbox1") );
                                              System.out.println("2nd checkbox value:"+ dynaform.get("checkbox2") );
    }Now if I check the first checkbox and press on submit button, the action class prints out:
    1st checkbox value: on
    2nd checkbox value: off
    this is as expected
    Now I click on the back button, then i uncheck the first checkbox and click on submit.
    the output is same as before, i.e.:
    1st checkbox value: on //wrong
    2nd checkbox value: off
    I expected it to be
    1st checkbox value: off
    2nd checkbox value: off
    That means if in a session if i check on checkbox 'on', and i go back and uncheck it, the uncheck is never stored, i.e. the property is never set to 'off' .
    Now if i check the second one, and click on submit, output is :
    1st checkbox value: on //expected off
    2nd checkbox value: on //correct
    now i go back and uncheck the 2nd checkbox (the first checkbox is already unchecked before), click submit and i get this output:
    1st checkbox value: on //expected off
    2nd checkbox value: on //expected off
    Please let me know what is happening. I expect the values of uncheck boxes to be 'off'
    thanks
    Tanveer

    The String[] thing is only useful when you have multiple checkboxes of the same name.
    What is the scope of the form bean? Request or session? If it's request, then that makes no sense. If it's session, then it does make sense because the same bean is being used, and as a result, the values are not really reset. And since HTML forms work by not submitting anything for unchecked checkboxes, then the server doesn't get anything in the request form data to know to change the checkbox to any other value.
    If you are using session scope, then make sure you have a good reason to. Otherwise, use request.

  • How to obtain checkbox checked/unchecked  while editing

    Hi All,
    My scenorio is,
    I have a form and on that form i have text field & checkbox.
    I am saving record by entering some value in text box & checking checkbox(if my checkbox checked then I am saving "Y" for that checkbox in DataBase).Its saving both things properly in databse.
    While editing , If i click on edit link , my text box value coming properly(i.e. value which I stored in databse. )
    But that checkbox is not coming in checked mode(i.e while saving I have checked checkbox)
    So how to obtain checkbox at the time of editing checked/unchecked as they were at the time of saving ?
    Thanks
    Sandip

    Hi,
    Thanks for your reply.
    Sorry my variable is userAdmin.
    I have getUserAdmin() method in the C.java(server side pojo )?
    But its return type is String.(return type String because I want to save "Y / N") while saving
    public class C{   // server side pojo
    private String userAdmin; // corresponding getter & setter
    lly, I have getUserAdmin() method in cleint side pojo
    public class B{ // client side pojo
    private boolean userAdmin; // corresponding getter & setter
    but while saving I am doing as,
    public class SaveClass
    public String saveMethod()
    C c = new C();
    B bb = new B();
    if (bb.getUserAdmin() == Boolean.TRUE)
    c.setUserAdmin("Y");
    else
    c.setUserAdmin("N");
    // in client side pojo userAdmin variable's return type is boolean for checking as,
    if (bb.getUserAdmin() == Boolean.TRUE)
    but on server side its String for saving "Y / N",
    if (bb.getUserAdmin() == Boolean.TRUE)
    aa.setUserAdmin("Y"); /// to save String here
    So if I write in JSP,
    <h:selectBooleanCheckbox value="#{BeanName.c.userAdmin}"/>
    its giving error as,
    javax.servlet.ServletException: Expected submitted value of type Boolean for Component : {Component-Path :.................                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Error on Checking/Unchecking "Show"

    I an a designer getting ready to train my client in
    Contribute CS3. I have considerable experience with optional
    editable areas in DW templates and training clients in how to make
    items visible and not visible.
    However, in my current website I receive an error whenever I
    check or uncheck the Show box. (Also, I am using the MM_swapImage
    behavior in the top menu.)
    Format>Template Properties > either click or unclick
    the Show checkbox for an editable optional area, I receive this
    error message.
    While executing onLoad in Swap Image.htm, the following
    JavaScript error(s) occurred:
    At line 303 of file "C:\Program Files\Adobe]Adobe Contribute
    CS3\Configuration\Behaviors\Actions\Swap Image.js";
    TypeError: dw.getBehaviorTag is not a function
    I then have to press the OK button on the error message 5 or
    more times, the error message then disappears, and I am able to
    click the Publish button and it successfully publishes the page.
    How can I prevent this error message from appearing.
    Here's a page on the site I'm building.
    http://www.sivitzdesigns.com/about.php

    In "Swap Image.js" change line 303
    from: if (!dw.getBehaviorTag())
    to: if (dw.getBehaviorTag && (!dw.getBehaviorTag()
    and change line 306
    from: if (dw.getBehaviorElement()) selTag =
    dw.getBehaviorElement().tagName;
    to: if (dw.getBehaviorElement &&
    dw.getBehaviorElement()) selTag = dw.getBehaviorElement().tagName;
    You'll have to change it on your user's computer. It's a
    Contribute problem, not a Dreamweaver problem. The complete code
    snippet with before and after is:
    function initializeUI(){
    var niceNameSrcArray=new Array(), nameArray, i, selTag="";
    var imgSrcArray = new Array();
    var endsWithZero = /\[0\]$/; //ref ends with [0]
    //Determine if RESTORE is an option. If not, remove UI for
    it
    //the dw.getBehaviorTag() check ensures the checkbox
    //is not available if a behavior is attached to a timeline
    var removeCheckbox = false;
    //david, this was: if (!dw.getBehaviorTag())
    if (dw.getBehaviorTag && (!dw.getBehaviorTag() ))
    //if behavior is in a timeline
    removeCheckbox = true;
    else {
    //david, this was: if (dw.getBehaviorElement()) selTag =
    dw.getBehaviorElement().tagName;
    if (dw.getBehaviorElement &&
    dw.getBehaviorElement()) selTag = dw.getBehaviorElement().tagName;
    and then the rest of the function.

  • How to check whether a checkbox is checked

    This code:
          if (checkBoxCSharpShown.IsChecked)
            checkBoxCSharpShown.IsChecked = false;
    elicits:
    "Cannot implicitly convert type 'bool?' to 'bool'. An explicit conversion exists (are you missing a cast?)"
    How can I check whether the checkBox is checked?
    Delphi ancient/C# newbie

    So why is this so complicated? Why doesn't a check box have a true/false value? The answer is that a checkbox can (optionally and not by default) be a three-state control.
    When ThreeState is true, the checkbox has three states:
    Checked
    Not Checked
    Indeterminate
    They correspond to these tests:
    bool checked = IsChecked.HasValue && IsChecked.Value == true
    bool unchecked = IsChecked.HasValue && IsChecked.Value == false
    bool indeterminate = IsChecked.HasValue == false
    One of the ways a three-state checkbox is used is in a property dialog. If the user selects multiple items (all having some boolean property called 'Active'--for instance), what should the proprety dialog show for that selection if the value of Active is different among the selected items? Should it show True? That wouldn't work, they are not all True, same for False. So instead the property dialog would show Indeterminate, indicating that the collection of Active values is neither True, nor False.
    Now having said all of that I'll refer you to:
    CheckBox.Checked
    This is true or false. If the ThreeState property is True, Checked returns True for True or Indeterminate.

  • In me21 I want to uncheck the checkbox 'info record update'.

    In me21 I want to uncheck the checkbox 'info record update'. This checkbox is checked by default. How can I uncheck it?.

    Hi,
        Goto SHD0 Tcode, give the Transaction name ME21N,
        Click on Screen Variant Tab,
        Give the
                   Screen Variant Name : ZINFO
                   Program : SAPLMEGUI
                   Screen : 1319
       Click on Create, it will take to the Tcode,
       Give any Material no, click on Expand item, ignore any errors
       In Material Data Tab, Check the Info Record check box. Click on Back
       It will show the Screen variant which u selected with its values,
       Give short text and Exit and save, Again save, it will ask for pacakage.
      Now goto Transaction variant, and look for the Standard variant used, add the created Screen variant to that standard variant. and activate.
    Next time you open that Tcode it will defaultly checked.
    Regards
    Bala Krishna

  • Can you check/uncheck multiple songs in iTunes for syncing to iPod?

    In a previous reply to this question, the answer given was that you can use Command apple key to uncheck or check groups of iTunes songs for syncing.
    Actually this does not work.
    Apple Commmand only gives you the possibility to check or uncheck the ENTIRE list of iTunes.. unless I am completely mad.
    There must be a way to select say 5 songs from an album and check/uncheck them all at the same time. So that you can make a fresh selection of songs each time you sync to an iPhone or iPod
    I simply cannot believe that iTunes is so dumb that this option is not available...
    ie what one needs to be able to do is highlight x number of songs at a time and then check or uncheck them as you go through the iTunes list to make a fresh syncing selection
    I hope this can be answered
    best
    MS

    AHXtreme42 wrote:
    Once you have all of the selected items, RIGHT CLICK (or alt click whatever) one of those highlighted items and select either CHECK or UNCHECK SELECTION.
    This is EXACTLY the point at which I get stuck - what is the actual key command for Right Click - it is not Alt Click or any combination, and looking for his in the iTunes help does not yield a result.
    Please give me that actual key stroke combination to effect this last operation: I have always been able to select multiple tracks in the way you describe with Shift - but how to actually CHECK and UNCHECK a selection.. once the tracks are selected
    Would much appreciate the answer to this

  • Uncheck a Checkbox when Select List Clicked

    version 4.0.2.00.06
    Hello,
    Jari helped me with a javascript function to select all options in a multi-select list when a checkbox is checked by the user.
    A bug was reported that after clicking the checkbox to select all the options in the list, if the user then clicks on a single value in the select list the checkbox is still checked.
    Would someone help me with how to uncheck the checkbox when a single value is selected in the select list after the checkbox is checked to select all of the options in the select list?
    If you need more information please let me know.
    Thanks,
    Joe

    Hi,
    Same sample as in this post
    Re: The requested URL /apex/wwv_flow.accept was not found on this server
    I did add page JavaScript
    function checkSelected(pThis,pChk,pVal){
    var self=$($x(pThis));
    var o=self.find("option");
    var s=self.find("option:selected");
    if(s.length==o.length){
      $s(pChk,pVal);
    }else{
      $s(pChk,"");
    }And to P65_EMP multiu select HTML Form Element Attributes
    onchange="checkSelected(this,'P67_SELECT_ALL','ALL')"Regards,
    Jari

  • How to check/uncheck all check boxes in an insert-not-allowed block

    Hi All,
    I have a column of check box which is placed in a multirow block. This block's INSERT_ALLOWED property is set to false. The column of check box is not a database item and its insert_allowed property is to true. Now I use the following code which is in when-button-pressed trigger to control checking/unchecking all the check boxes:
    go_block('selected_payment');
    first_record;
    loop
    :cb_payflag:= 'N'; -- uncheck the check box
    exit when (:system.last_record = 'true');
    next_record;
    end loop;
    It gives me 'FRM-41051 Cannot create records here' error, and it goes into an infinite loop. It looks like it never reaches the last record where the block actually contains two records.
    Please help!
    Thanks in advance.
    Regards,
    Vanessa

    It sounds like your block does not have a field where the cursor focus can go when looping through the records. Create a dummy non-db field in the block which is enabled and has insert/update allowed. see if it then works. If it does then you can shrink the field down to 1x1 pixels with no border so the user cannot ever click on it and it's invisible.

  • Credit value used in credit check

    Hi,
    Could any one help me understand how credit value is calculated in credit check for sales orders.
    I was assuming that credit value is undelivered value returned by fm -SD_CREDIT_VALUE_ORDER.
    When i debug this fm gives me different value each time.Acoording to the config Total amount of order(incl tax) should be used for credit check.
    Thanks in advance.
    Priya.

    Hope you have released the credit block and then when you are changing any parameter(other than qty and value) the order is going on credit check again? If yes, in OVA8 - under " Released orders are still unchecked" maintain number of days or percentage of change of value. Then the reeleased orders will not be checked again .
    If you havent released the credit blocked order and when ever you do any changes to order and save it, you will get the credit blocked message all the times. If the amount is not consistent then may be you can execute few programs to reset the open credit value of the customers. Please refer to the below notes for incorrect credit values.
    Note 1176872 - Composite SAP Note Incorrect credit Updated
    Note 124571 - Incorrect credit values S066 S067 FD32
    Note 377165 - Update open credit values for credit management
    Note 716141 - Analysis Incorrect open credit values
    Note 425483 Consulting notes Credit Checks
    Regards
    Sai

Maybe you are looking for