Results 1 to 2 of 2

Thread: ReversedGridSelectionModel

  1. #1
    Ext User
    Join Date
    Sep 2008
    Location
    Germany
    Posts
    959

    Default ReversedGridSelectionModel

    if you like your selection like always the ctrl key is pressed to select rows you can use this selection model:

    PHP Code:
    package org.yournamehere.client.gui.components;

    import com.extjs.gxt.ui.client.Style.SelectionMode;
    import com.extjs.gxt.ui.client.data.ModelData;
    import com.extjs.gxt.ui.client.event.GridEvent;
    import com.extjs.gxt.ui.client.widget.grid.GridSelectionModel;
    import com.extjs.gxt.ui.client.widget.grid.GridView;
    import java.util.Arrays;

    /**
     *
     * @param <M> the model type contained within the store
     * @author anonym
     */
    public class ReversedGridSelectionModel<extends ModelData> extends GridSelectionModel<M> {

        @
    Override
        
    protected void handleMouseDown(GridEvent<Me) {
            if (
    isLocked()) {
                return;
            }
            if (
    e.isRightClick()) {
                if (
    e.getRowIndex() != -1) {
                    if (
    isSelected(listStore.getAt(e.getRowIndex())) && selectionMode != SelectionMode.SINGLE) {
                        return;
                    }
                    
    select(e.getRowIndex(), false);
                }
            } else {
                
    GridView view grid.getView();
                
    M sel listStore.getAt(e.getRowIndex());

                if (
    selectionMode == SelectionMode.SINGLE) {
                    if (
    isSelected(sel) && e.isControlKey()) {
                        
    deselect(sel);
                    } else if (!
    isSelected(sel)) {
                        
    select(selfalse);
                        
    view.focusCell(e.getRowIndex(), e.getColIndex(), true);
                    }
                } else {
                    if (
    e.isShiftKey() && lastSelected != null) {
                        
    int last listStore.indexOf(lastSelected);
                        
    int index e.getRowIndex();
                        
    int a = (last index) ? index last;
                        
    int b = (last index) ? index last;
                        
    select(abe.isControlKey());
                        
    lastSelected listStore.getAt(last);
                        
    view.focusCell(indexe.getColIndex(), true);
                    } else if (
    isSelected(sel) && !e.isControlKey()) {
                        
    doDeselect(Arrays.asList(sel), false);
                    } else {
                        if (
    isSelected(sel) && e.isControlKey()) {
                            return;
                        }
                        
    doSelect(Arrays.asList(sel), !e.isControlKey(), false);
                        
    view.focusCell(e.getRowIndex(), e.getColIndex(), true);
                    }
                }
            }
        }

    see http://extjs.com/forum/showthread.ph...485#post374485

  2. #2
    Ext User
    Join Date
    Sep 2008
    Location
    Germany
    Posts
    959

    Default

    something similar for CheckboxSelectionModel

    ExtendedCheckBoxSelectionModel
    http://www.extjs.com/forum/showthread.php?t=81701

Posting Permissions

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