Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: Disable Checkboxes in CheckBoxListView

  1. #1
    Sencha Premium User
    Join Date
    Aug 2009
    Location
    Heidelberg
    Posts
    5
    Vote Rating
    0
      0  

    Default Disable Checkboxes in CheckBoxListView

    Hey,

    i try to use the CheckBoxListView to show some uneditable information. This works fine but in this view i don't want the user to be able to select any of the checkboxes. Does anybody know how to implement this?

    i tried CheckBoxListVie.disable(). This makes the component grey but i can still select the check boxes.

    i tried getSelectionModel().setLocked( true ) but i can still select the check boxes.

    Thanxs in advance
    Lars

  2. #2
    Sencha Premium Member
    Join Date
    Sep 2007
    Posts
    13,976
    Vote Rating
    131
      0  

    Default

    Add a click listener to the listview. If the target is the checkbox that is not allowed to be checked, prevent the default action.

  3. #3
    Ext Premium Member
    Join Date
    Sep 2009
    Posts
    77
    Vote Rating
    0
      0  

    Default

    I also have to deal with this issue.
    I set the CheckBoxListView disabled (checkBoxListView.setEnabled(false)), it gets grayed out, which is fine, but once I clicked by mistake and was happy to see that the checkbox actually got clicked.
    My personal opinion is that setting a widget disabled should not allow the user do operations that change the state of that widget. At least this is how it is on other UI platforms: Swing, SWT, Android,...

    Anyway, I tried to follow your suggestion and it doesn't work. The OnClick event is not even issued when I click on a disabled checkbox.

    Regards,

    Dan

  4. #4
    Sencha Premium Member
    Join Date
    Sep 2007
    Posts
    13,976
    Vote Rating
    131
      0  

    Default

    If you disable it, than there wont be any events.

    Two solutions:

    disable and mask the CheckBoxListView or dont disable it and lock the selectionmodel and prevent the default action if the target is a checkbox.

  5. #5
    Ext Premium Member
    Join Date
    Sep 2009
    Posts
    77
    Vote Rating
    0
      0  

    Default

    I tried the second approach by doing this:
    Code:
     
    checkBoxListView.getSelectionModel().setLocked(true);
    checkBoxListView.addListener(Events.OnClick, new Listener<BaseEvent>() {
      public void handleEvent(BaseEvent e) {
        e.setCancelled(true);
      }
    });
    It looks like I still can check and uncheck the checkboxes. Any ideas?

  6. #6
    Sencha Premium Member
    Join Date
    Sep 2007
    Posts
    13,976
    Vote Rating
    131
      0  

    Default

    Code:
    view.getSelectionModel().setLocked(true);
        view.addListener(Events.OnClick, new Listener<ListViewEvent<BeanModel>>() {
          public void handleEvent(ListViewEvent<BeanModel> e) {
            if (e.getTarget().getTagName().equalsIgnoreCase("input")) {
              e.preventDefault();
            }
          }
        });
    I run this against GXT 2.2 and it was working fine.

    canceling an event does not prevent the default action.

  7. #7
    Ext Premium Member
    Join Date
    Sep 2009
    Posts
    77
    Vote Rating
    0
      0  

    Default

    Sven,

    How could I implement the "disable and mask the CheckBoxListView". I know how to disable, but not sure how to mask it.

    Thanks,

    Dan

  8. #8
    Sencha Premium Member
    Join Date
    Sep 2007
    Posts
    13,976
    Vote Rating
    131
      0  

    Default

    Code:
    view.mask("Disabled");

  9. #9
    Ext Premium Member
    Join Date
    Sep 2009
    Posts
    77
    Vote Rating
    0
      0  

    Default

    Code:
    view.setEnabled(false);
    view.mask("Disabled");
    I see the "Disabled" message before the view is populated, the view looks disabled, but I still can click in it and checkboxes change state.

  10. #10
    Sencha Premium Member
    Join Date
    Sep 2007
    Posts
    13,976
    Vote Rating
    131
      0  

    Default

    Due to the way ListView works, you can first mask it after loading the data/the view showing the data.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •