1. #61
    Sencha User
    Join Date
    Mar 2009
    Posts
    71
    Vote Rating
    0
    SantaBarbarian is on a distinguished road

      0  

    Default


    Thank you. I'll take a look at that.

  2. #62
    Ext User
    Join Date
    Oct 2008
    Posts
    195
    Vote Rating
    0
    aj3423 is on a distinguished road

      0  

    Default


    Quote Originally Posted by joeri View Post
    I still had an issue when doing multi-select of rows with the shift button. It would select a block of text.

    To workaround this, I used a custom selModel defined on the gridpanel:
    Code:
                var sm = new Ext.grid.RowSelectionModel();
                sm.on('selectionchange', function(sm) {
                   // only clear text selection when selecting more than one row (shift-select)
                   if (sm.getSelections().length > 1) {
                      // use setTimeout, because the event still has to cascade to the browser
                      // for the text selection to happen
                      window.setTimeout(function() {
                         // for mozilla
                         if (window.getSelection) { getSelection().removeAllRanges() }
                         // for IE
                         else if (document.selection) { document.selection.empty(); };
                         }
                      , 0);
                   };
                });
    when selecting text with SHIFT key, the text is selected and then unselected, so there'll be a flash with this hack, I'm testing it in IE8, there should be some way to disable the text selection when SHIFT key is down ?

  3. #63
    Ext User
    Join Date
    Oct 2008
    Posts
    195
    Vote Rating
    0
    aj3423 is on a distinguished road

      0  

    Default


    problem 1:
    in IE, when multi-select with SHIFT key, all the text will be selected
    problem 2:
    override of prototype.templates

    see this thread:
    http://www.sencha.com/forum/showthre...id-quot-in-FAQ

  4. #64
    Ext User
    Join Date
    Jun 2008
    Posts
    13
    Vote Rating
    0
    bk1 is on a distinguished road

      0  

    Red face This works!

    This works!


    Thanks, Condor and DK!

    (Was this enabled by default in 2.1, I wonder....)

  5. #65
    Sencha User
    Join Date
    May 2008
    Location
    Germany
    Posts
    19
    Vote Rating
    3
    vpopa is on a distinguished road

      0  

    Default


    I found a problem if there a second row in the grid defined in the getRowClass method.

    I've noticed that second row disappear because something beyond my understandings happens in the next line:
    Code:
    Ext.grid.GridView.prototype.templates = {};
    Then I've noticed that another solution that allows you to select text in a grid, is just to return the x-selectable class in the getRowClass, but I've only tested on Firefox.
    Code:
    viewConfig: {
     getRowClass: function(record, rowIndex, rp, ds){
      return "x-selectable";
     }
    }
    Condor would you be kind and tell me if it's ok to use the following code in order to aviod the problem that I've mention above:
    Code:
    Ext.override(Ext.grid.GridView, {
        cellTpl: new Ext.Template(
            '<td class="x-grid3-col x-grid3-cell x-grid3-td-{id} x-selectable {css}" style="{style}" tabIndex="0" {cellAttr}>',
                '<div class="x-grid3-cell-inner x-grid3-col-{id}" {attr}>{value}</div>',
            '</td>'
        )
    });
    The code above makes the text selectable in all grids and you also have the second row in the grid display.
    Please note that in order to be able to select the text in the second row also the getRowClass must return the x-selectable class.

  6. #66
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    96
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    Your override should ofcourse only contain the second cellTpl, and yes, it will also work (but only on Ext 3.3+, because older versions didn't have a cellTpl GridView property).

  7. #67
    Sencha User
    Join Date
    May 2008
    Location
    Germany
    Posts
    19
    Vote Rating
    3
    vpopa is on a distinguished road

      0  

    Default


    ups, I updated the code.

    thz for the answer

  8. #68
    Ext JS Premium Member
    Join Date
    Nov 2009
    Location
    San Diego, CA
    Posts
    158
    Vote Rating
    0
    locutusUT is on a distinguished road

      0  

    Default


    Thanks for the contribution Condor. I'm trying to do the same in Ext JS 4 but I'm not exactly sure which class I should override. I see the code in the distro, but I can't seem to override it without a JavaScript error.

    Code:
    Ext.override( Ext.view.TableChunker, {
        metaRowTpl: [
            '<tr class="' + Ext.baseCSSPrefix + 'grid-row {addlSelector} {[this.embedRowCls()]}" {[this.embedRowAttr()]}>',
                '<tpl for="columns">',
                    '<td class="{cls} ' + Ext.baseCSSPrefix + 'grid-cell ' + Ext.baseCSSPrefix + 'grid-cell-{columnId} {{id}-modified} {{id}-tdCls} {[this.firstOrLastCls(xindex, xcount)]}" {{id}-tdAttr}><div unselectable="off" class="' + Ext.baseCSSPrefix + 'grid-cell-inner ' + Ext.baseCSSPrefix + 'unselectable" style="{{id}-style}; text-align: {align};">{{id}}</div></td>',
                '</tpl>',
            '</tr>'
        ]
    });
    I also tried this CSS override which works fine for FF but not for webkit browsers:

    Code:
        <style type="text/css">
            .x-unselectable, .x-unselectable * {
                -moz-user-select: inherit !important;
                -webkit-user-select: text !important;
                -khtml-user-select: text !important;
            }
        </style>
    Thoughts to get this working in Ext JS 4?

  9. #69
    Ext JS Premium Member Jonny5's Avatar
    Join Date
    Jan 2010
    Location
    Vancouver, BC
    Posts
    30
    Vote Rating
    0
    Jonny5 is on a distinguished road

      0  

    Default


    I too would love the ability to select text in a grid in this way. I want to be able to swipe and copy all table contents.

  10. #70
    Sencha User
    Join Date
    Jan 2010
    Posts
    30
    Vote Rating
    0
    new is on a distinguished road

      0  

    Default


    Hi everyone
    I just want to be able to select text from a TreeGrid panel cells. I tried all the mentioned way but no result. please help. thanks
    it serious