Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    List Grid Selection Checkbox Problem (cannot Select/unselect on checkbox)

    SmartGWT 2.6.1

    Google Chrome Browser.

    Hello Everyone,

    I have a requirement where "onRecordClick", the entire row need to be selected. Here is my code:
    ListGrid grid = new ListGrid();
    .
    .
    .
    grid.setSelectionType(SelectionStyle.SIMPLE);
    grid.setSelectionAppearance(SelectionAppearance.CHECKBOX);

    grid.addRecordClickHandler(new RecordClickHandler() {
    @Override
    public void onRecordClick(RecordClickEvent event) {
    if (grid.isSelected(event.getRecord())){
    grid.setSelectionProperty(null);
    grid.deselectRecord(event.getRecord());
    }else{
    grid.setSelectionProperty("isSelected");
    grid.selectRecord(event.getRecord());
    }


    }
    });

    My problem is that, the checkbox no longer works after this code. i.e the record state is set to selected on click, but if i try to change the checkbox state directly , it does not work.

    Can you please help?

    Thank You,
    Michaël.

    #2
    It doesn't make any sense to set a null selectionProperty; if that were valid, the effect would be that selection stops working. There doesn't appear to be any reason why you'd change the selectionProperty at all.

    Can you try explaining again what you want? Do you want rows that are selected to appear with special selection styling (even though this is visually redundant with the checkbox showing as checked)?

    Comment


      #3
      Yes you are right. I have a context menu for each line. I was trying to get focus on the line where the user was selecting the menu. (the context menu was created through createRecordComponent))

      I have abandoned the idea of doing this (i.e there was a much neater way to do it.). So my code have only the following code now:

      grid.setSelectionType(SelectionStyle.SIMPLE);
      grid.setSelectionAppearance(SelectionAppearance.CHECKBOX);

      the get focus is handled in createRecordComponent​.

      Thanks for your time and help.

      Michaël

      Comment

      Working...
      X