Results 1 to 2 of 2

Thread: ExtendedCheckBoxSelectionModel

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

    Default ExtendedCheckBoxSelectionModel

    a little bit like this but also for GridSelectionModel

    ReversedGridSelectionModel
    http://www.extjs.com/forum/showthread.php?t=78522


    its a drop in replacement for CheckBoxSelectionModel

    new parameters
    setCheckBoxOnly(true) - only checkboxes are trigger a selection change
    setCheckBoxSynchronized(true) - let clicks in the list act the same like click the checkbox


    PS:
    i dont like my new names so very much. there are some better suggestions for naming?


    PHP Code:
    /*
     * 
     * @author anonym
     */
    package com.mycompany.myapplication.client.gui.components;

    import com.extjs.gxt.ui.client.data.ModelData;
    import com.extjs.gxt.ui.client.event.GridEvent;
    import com.extjs.gxt.ui.client.widget.grid.CheckBoxSelectionModel;
    import com.google.gwt.user.client.Event;
    import java.util.Arrays;

    /**
     * A grid selection model and component plugin. To use, add the column config to
     * the column model using {@link #getColumn()} and add this object to the grids
     * plugin.
     * added more settings
     *
     * @param <M> the model data type
     */
    public class ExtendedCheckBoxSelectionModel<extends ModelData> extends CheckBoxSelectionModel<M> {

        private 
    boolean checkBoxOnly false;
        private 
    boolean checkBoxSynchronized false;

        public 
    ExtendedCheckBoxSelectionModel() {
            
    super();
        }

        @
    Override
        
    protected void handleMouseDown(GridEvent e) {
            if (
    checkBoxOnly || checkBoxSynchronized) {
                if (
    e.getEvent().getButton() == Event.BUTTON_LEFT && ((checkBoxSynchronized && !checkBoxOnly) || e.getTarget().getClassName().equals("x-grid3-row-checker"))) {
                    
    M m listStore.getAt(e.getRowIndex());
                    if (
    != null) {
                        if (
    isSelected(m)) {
                            
    doDeselect(Arrays.asList(m), false);
                        } else {
                            
    doSelect(Arrays.asList(m), truefalse);
                        }
                    }
                }
            } else {
                
    super.handleMouseDown(e);
            }
        }

        
    /**
         * this is true if only the CheckBox can be clicked to toggle a Selection
         * @return checkBoxOnly
         */
        
    public boolean isCheckBoxOnly() {
            return 
    checkBoxOnly;
        }

        
    /**
         * Set this to true if only the CheckBox can be clicked to toggle a Selection
         * default: false
         * @param checkBoxOnly
         */
        
    public void setCheckBoxOnly(boolean checkBoxOnly) {
            
    this.checkBoxOnly checkBoxOnly;
        }

        
    /**
         * this is true if clicking in the list is the same as clicking on the checkbox
         * @return checkBoxSynchronized
         */
        
    public boolean isCheckBoxSynchronized() {
            return 
    checkBoxSynchronized;
        }

        
    /**
         * Set this to true to act with clicking in the list the same as clicking on the checkbox
         * default: false
         * @param checkBoxSynchronized
         */
        
    public void setCheckBoxSynchronized(boolean checkBoxSynchronized) {
            
    this.checkBoxSynchronized checkBoxSynchronized;
        }

    This forum needs your help: you got hints from the community and now you have fixed your code? dont just reply with "now its fixed" or "i found the error"! please take the time to post also an detailed answer with the working code.

    GreaseMonkey Script for a GXT-only Forum: it hides ExtJs here: New Posts Search Results Advanced Search form Category overview http://www.extjs.com/forum/showthrea...041#post410041

  2. #2
    Ext User
    Join Date
    Oct 2008
    Location
    Atlanta ,GA
    Posts
    239

    Default

    Thanks a lot buddy..
    This was really helpful..

Posting Permissions

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