1. #11
    Ext User
    Join Date
    May 2008
    Posts
    2
    Vote Rating
    0
    thephatness is on a distinguished road

      0  

    Default Great plugin

    Great plugin


    Hi Noah,

    Thanks for the great work on this...

    I'm having a problem with the 'checked' dataIndex. What's happening is that all checks are being rendered backwards so to get it working right I would have to pass in 'checked':'false' for checked and 'checked':'true' for unchecked. Maybe it's late and I'm not reading it right but I've defined the SM just like in your usage guideline, and added a few listener functions to handle select/deselect AJAX requests. I wasn't sure what you meant by "Just add the selectionModel to your reader..." but I'm using the SM in the column model and selection model param for the datagrid. I also notice that when paging through the datagrid, for a split second, all checkboxes get checked and unchecked. Other than that everything works fine. I'll look into this more tomorrow and step it through Firebug. Thanks!

  2. #12
    Ext JS Premium Member NoahK17's Avatar
    Join Date
    Apr 2008
    Location
    Atlanta, GA
    Posts
    518
    Vote Rating
    1
    NoahK17 is on a distinguished road

      0  

    Default


    Hrm, interesting. Here's how I have it set up:

    Code:
    // Create the data store
    var myDataStore = new Ext.data.JsonStore({
      url: '/repository/libs/php/grid-data.php',
      root: 'data',
      totalProperty: 'totalCount',
      id: 'id',
      fields: [
        {name: 'checked', type: 'bool'}
      ]
    });
    
    // Define the selection model (checkbox)
    var sm = new Ext.grid.SmartCheckboxSelectionModel({
    	dataIndex:'checked'
    });
    
    var cm = new Ext.grid.ColumnModel([
    	sm
    ]);
    
    var grid = new Ext.grid.GridPanel({
     cm: cm,
     sm: sm,
     ds: myDataStore,
     width: 100,
     height: 100
    });
    
    // Code to render your grid
    ...
    
    // Trigger the data store load
    myDataStore.load({params:.........});
    My JSON response would look simply like:
    PHP Code:
    {"totalCount":2,"data":[{"checked":"false""id":"1"}, {"checked":"true""id":"2"}]} 
    Noah
    Senior Web Developer
    NBA.com

  3. #13
    Ext User
    Join Date
    May 2008
    Posts
    2
    Vote Rating
    0
    thephatness is on a distinguished road

      0  

    Default


    Thanks, that example is helpful. It was my lazy definition of fields: ['checked', 'field1', 'field2',...etc] instead of specifying fields: [{name: 'checked', type: 'bool'},... that caused the problem.

  4. #14
    Ext User
    Join Date
    Mar 2008
    Posts
    2
    Vote Rating
    0
    iuri.andreazza is on a distinguished road

      0  

    Default


    Hello! I put 'header:false" to not show the check in header, when the store loaded the data, the load event has an error and could not select the lines in the grid.

    Then I fixed your code, is just only one more IF.


    On the initEvents
    Code:
    Code:
    if (this.grid.store){
          this.grid.store.on('load', function(p){
               var t = Ext.get('x-grid3-hd-checker');
                     if(t != null){
    	                if(t.dom.className == 'x-grid3-hd-checker' && Ext.state.Manager.loaded){
    	                    var hd = Ext.fly(t.dom.parentNode);
    	                    var isChecked = hd.hasClass('x-grid3-hd-checker-on');
    	                    if(isChecked){
    	                        hd.addClass('x-grid3-hd-checker-on');
    	                        this.selectAll();
    	                        this.selectAllChecked(true);
    	                    }
    	                }
                    }
    //... code

  5. #15
    Ext JS Premium Member NoahK17's Avatar
    Join Date
    Apr 2008
    Location
    Atlanta, GA
    Posts
    518
    Vote Rating
    1
    NoahK17 is on a distinguished road

      0  

    Default


    Updated to v1.4:
    - new config options, "email" and "excel"

    email: Setting email to true or false in the selection model constructor changes the default behavior of the checkboxes. If set to true, clicking a checkbox will NOT change the row selection, it will ONLY check or uncheck the checkbox itself. This mimics the way various "email clients" behave, like Yahoo! or Gmail! Having email set to true allows you to apply different actions on your grid rows based on whether they are checked OR selected. If set to false, clicking a checkbox will also select the row and vice-versa. This setting defaults to false.

    excel: Setting excel to true or false changes the way row selection works. If excel is set to true, clicking on a row will deselect all other rows, except for the row you just clicked. If set to false, all previous row selections will remain selected as you click around (just as if you were holding down CTRL and clicking a new row). This setting defaults to false.

    Cheers!
    Noah
    Senior Web Developer
    NBA.com

  6. #16
    Ext User
    Join Date
    Oct 2007
    Posts
    23
    Vote Rating
    0
    Max Ishchenko is on a distinguished road

      0  

    Default


    I'm using the SmartCheckboxSelectionModel in a grid which is hidden by default. It's located in a tab with lazy loading.
    I use loadData for loading the store, and checkboxes are checked correctly, but the rows with checked checkboxes are not selected. When clicking on the raw that was checked (but not selected) it gets checked, and the checkbox remains checked. Next clicks check/uncheck the checkbox and select/deselect the row.
    I'd like to have not only checkboxes checked, but rows selected on load.
    It seems that 'load' event listener does this, but it is not being invoked at all when using loadData (or supplying 'data' config option in store config).

  7. #17
    Ext User
    Join Date
    Oct 2007
    Posts
    23
    Vote Rating
    0
    Max Ishchenko is on a distinguished road

      0  

    Post


    My problem is solved now.
    If you use inline data for your store (i.e. 'data' config parameter) the selectionmodel won't be attached to 'load' event listeners yet. Thus, no rows will be actually selected.
    The solution is like
    Code:
    mygrid.on('render', function () {
        this.getStore().loadData(mydata)
    })

  8. #18
    Ext JS Premium Member NoahK17's Avatar
    Join Date
    Apr 2008
    Location
    Atlanta, GA
    Posts
    518
    Vote Rating
    1
    NoahK17 is on a distinguished road

      0  

    Default


    Score! Glad you figured it out
    Noah
    Senior Web Developer
    NBA.com

  9. #19
    Sencha Premium Member
    Join Date
    Nov 2007
    Location
    Moore, Oklahoma
    Posts
    486
    Vote Rating
    15
    Mthor will become famous soon enough

      0  

    Default


    is there a way to have email set to true and when check box is checked the row gets selected.

    I need to only be able to check the check box, but the row gets selected when the check box is selected.

    and if clicked anywhere on the row nothing happens

    thanks

  10. #20
    Ext JS Premium Member NoahK17's Avatar
    Join Date
    Apr 2008
    Location
    Atlanta, GA
    Posts
    518
    Vote Rating
    1
    NoahK17 is on a distinguished road

      0  

    Default


    Sure, you'd just have to add a new config option... then do an if/else statement in the store.load function.

    Example:

    Code:
    var sm = new Ext.grid.SmartCheckboxSelectionModel({
        dataIndex:'checked',
        email:true,
        mthor:true
    });
    Around line 132
    Code:
    if((dataIndexValue == true || isSelected) && !Ext.state.Manager.loaded){
    // This code will only run the first time a grid is loaded 
    // Make sure that any "checked" rows are also selected
        if(!this.email || this.mthor){ this.grid.getSelectionModel().selectRow(i, true); }
    }
    Then go through the rest of the code and look for !this.email -- and anywhere you want that functionality to be over-ridden (e.g. clicking of checkboxes), just add the || this.mthor piece of code. The || stands for ELSE.

    Cheers!
    Noah
    Senior Web Developer
    NBA.com

Similar Threads

  1. Smart tooltip
    By same66 in forum Ext 3.x: Help & Discussion
    Replies: 4
    Last Post: 24 Feb 2011, 7:02 PM
  2. Ext.each : with remove - not smart enough
    By DaveC426913 in forum Sencha Touch 1.x: Discussion
    Replies: 5
    Last Post: 30 Nov 2010, 10:36 AM
  3. Is smart rendering possible in grid???
    By jeff77 in forum Ext 3.x: Help & Discussion
    Replies: 2
    Last Post: 10 Sep 2010, 12:03 AM
  4. Smart Ext toolbar
    By tinnt in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 20 Nov 2008, 7:04 PM
  5. GridPanel - smart rendering
    By embolooloo in forum Ext 2.x: Help & Discussion
    Replies: 4
    Last Post: 8 Oct 2007, 7:57 PM

Thread Participants: 62