Results 1 to 3 of 3

Thread: How to disable entire column with CellEditing Plugin

  1. #1
    Sencha User
    Join Date
    Aug 2011
    Posts
    28
    Vote Rating
    0
      0  

    Default How to disable entire column with CellEditing Plugin

    Hi,

    I am having editable grid with 4 columns as editable and other 3 non editable. I want to make those all 4 column un-editable on certain condition, let's say when user has only view access.

    Below is the code I am having

    Code:
    var cellPressureEditing = Ext.create('Ext.grid.plugin.CellEditing', {
              clicksToEdit: 1
            });
    
    var pressureCols = [
    {id:'Month',header: "Month", width: 50, sortable: true, dataIndex: 'month',
                field: {
                    xtype: 'combobox',
                    typeAhead: true,
                    triggerAction: 'all',
                    selectOnTab: true,
                    store: [
                        ['JAN','JAN'],
                        ['FEB','FEB'],
                        ['MAR','MAR'],
                        ['APR','APR'],
                        ['MAY','MAY'],
                        ['JUN','JUN'],
                        ['JUL','JUL'],
                        ['AUG','AUG'],
                        ['SEP','SEP'],
                        ['OCT','OCT'],
                        ['NOV','NOV'],
                        ['DEC','DEC']
                    ],
                    lazyRender: true,
                    listClass: 'x-combo-list-small'
                }
              },
    .............
    ]
    var pressureGridNew = new Ext.grid.GridPanel({
                id               : "pressure-grid",
                ddGroup          : 'gridDDGroup',
                store            : pressureGridStoreNew,
                columns          : pressureCols,
                enableDragDrop   : true,
                stripeRows       : true,
                autoExpandColumn : 'name',
                width            : 610,
                height           : 400,
                plugins          :[cellPressureEditing]
            });
    
    Ext.getCmp('pressureGridPanel').add('pressure-grid');
            if(siteAccess=='View'){
              //var headCount = pressureGridNew.headerCt.gridDataColumns.headerCounter;
              
              var plug = pressureGridNew.getPlugin();
              plug.clicksToEdit = 0;
              plug.cancelEdit();
            }
    In Firebug I can see that clicksToEdit is set to 0 in pressureGridNew and plug objects, but still I am getting dropdown which is edit field in those 4 columns in each cells.

    Hope to hear from you guys.

    -Ankit
    Last edited by Ankit.Desai; 20 Dec 2011 at 1:04 PM. Reason: Typo

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,381
    Answers
    3997
    Vote Rating
    1536
      0  

    Default

    The plugin has a beforeedit event that you can hook in to.
    Mitchell Simoens @LikelyMitch
    Modus Create, Senior Frontend Engineer
    ________________
    Need any sort of Ext JS help? Modus Create is here to help!

    Check out my GitHub:
    https://github.com/mitchellsimoens

  3. #3
    Sencha User
    Join Date
    Aug 2011
    Posts
    28
    Vote Rating
    0
      0  

    Default

    Thanks mitchellsimoens. It works.

    I found that solution in Grid FAQ but did not try it, may be because of Giants defeat against Skins.


    Below is the code part where I have implemented it for others reference.

    var cellPressureEditing = Ext.create('Ext.grid.plugin.CellEditing', {
    clicksToEdit: 1,
    listeners : {
    beforeedit : function(e) {
    if(siteAccess=='View'){
    if(e.colIdx == 0 || e.colIdx == 1 || e.colIdx == 2){ // columns Which are not editable in first place
    return true;
    }else{ // Other columns Which are editable which are wanted to be non-editable.
    return false;
    }
    }
    }
    }
    });
    Thanks again.

    -Ankit
    Last edited by Ankit.Desai; 21 Dec 2011 at 6:56 AM. Reason: Typo

Tags for this Thread

Posting Permissions

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