Announcement

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

    Click to the header of the ListGrid

    SmartGWT version: SC_SNAPSHOT-2011-07-18

    Hello,

    I have a ListGrid with data loaded from the Datasource that uses a REST-Service from my backend application.

    One of my use-cases is to implement possiblity to mark ALL records as selected using checkboxes.

    I've used:
    setSelectionType(SelectionStyle.SIMPLE);
    setSelectionAppearance(SelectionAppearance.CHECKBOX);

    and now I have a situation with disabled header checkbox and a warning:
    "Can't select that many records at once. Please try working in smaller batches"

    described here:
    http://forums.smartclient.com/showthread.php?t=10295

    I would like to implement following workaround for my use-case:
    - If user clicks to the header checkbox, I display the confirmation "Do you want to load all data" and force loading of ALL data into the grid

    I've found the way how to handle the click to the header checkbox, BUT:

    - How to enable the row header checkbox (without hacks) if there are more data as can be displayed in the grid? Is it possible to override some methods of the ListGrid to achive that?

    - It would even help, if I can replace the header checkbox with own control, does it work?


    Many thanks in advance

    Best regards
    Vitbit
    Last edited by vitbit1978; 18 Jan 2012, 04:00.

    #2
    For every one who is interesting how to achieve that.

    I didn't find any API methods allowing that, but you have a possiblity to overlap the checkbox in the header with you own control.
    The code is something like that:
    DynamicForm df = new DynamicForm();
    df.setWidth(28);
    df.setHeight(35);
    df.setStyleName("headerBar");
    df.setLayoutAlign(VerticalAlignment.CENTER);
    CheckboxItem customHeaderCheckBoxItem = new CheckboxItem();
    customHeaderCheckBoxItem.setWidth(28);
    customHeaderCheckBoxItem.setHeight(30);
    customHeaderCheckBoxItem.setShowTitle(false);
    customHeaderCheckBoxItem.setLabelAsTitle(true);
    customHeaderCheckBoxItem.setAlign(Alignment.CENTER);

    customHeaderCheckBoxItem.addChangeHandler(new ChangeHandler() {
    @Override
    public void onChange(final ChangeEvent event) {
    if (event.getValue()!=null && ((Boolean)event.getValue())) {
    //Handling for select all
    } else {
    //Handling for deselect all
    }
    }
    });
    df.setFields(customHeaderCheckBoxItem);
    //Add child adds this checkbox to the top left corner,
    //exact the place, where defaut checkbox is displayed
    myListGrid.addChild(df);

    Comment


      #3
      And then, what do you do for "select all"? Setting fetch-mode back to basic (disabling pagination) and reloading the grid data? Or...?

      Comment

      Working...
      X