Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Disable grid row

  1. #1

    Default Answered: Disable grid row

    Hello everyone,

    (ExtJS 6 - classic toolkit)

    I have a grid with 4 columns (one of them is an actioncolumn).
    Based on custom events, I'd like to disable/enable (dynamically!) specific rows of a grid.
    Ideally I'd like to grey those rows over and disable the actioncolumn function but whatever works will do the trick.

    After going through the documentation and the threads of the forum I still come out empty.

    I understand that function such as:
    Code:
    grid.getView().getRow(index)
    return an HTML element and not an Ext element.
    Is there any hidden magic I should be aware about?

    Thanks in advance!

    Pierre

  2. You can use the getRowClass method to set a CSS class on the whole row. You can then define your styles to affect the cells as you wish.

    http://docs.sencha.com/extjs/6.5.0/c...od-getRowClass

  3. #2
    Sencha User
    Join Date
    Feb 2013
    Location
    California
    Posts
    11,985
    Answers
    506

    Default

    I'm afraid that there's nothing built into the framework to disable grid rows, but perhaps you can achieve it with CSS. The action column part is there for you:
    http://docs.sencha.com/extjs/6.5.0/c...od-setDisabled

  4. #3
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,448
    Answers
    3997

    Default

    You can use the getRowClass method to set a CSS class on the whole row. You can then define your styles to affect the cells as you wish.

    http://docs.sencha.com/extjs/6.5.0/c...od-getRowClass
    Mitchell Simoens @LikelyMitch

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

    Posts are my own, not any current, past or future employer's.

  5. #4

    Default

    Hello both of you,

    Ok thanks for your answer, I'll try to work around the CSS then.

    Have a good day.

  6. #5

    Default

    Weird, I just came up against a similar requirement. Perfect timing. I needed to disable a grid row and any editor components within it (dropdowns etc.)
    Below is what works for me (I've removed a lot of the gridpanel config options just so you can see the main stuff here). .disabled-grid-row is a custom css class, so you'll need to define that in your .scss, preferably scoped to this particular grid (if you've others in your app, you don't want them to get the same styling), hence the .model-work-item-grid class parent class I have on the gridpanel (in my instance, I'm also using the parent class for additional styling, so it wasn't just added for this functionality).

    Code:
    {
      xtype: 'gridpanel',
      layout: 'fit',
      cls: 'model-work-item-grid',
      columnLines: true,
      reference: 'modelWorkItemGrid',
      selModel: {
        selType: 'checkboxmodel'
      },
      plugins: [{
        ptype: 'cellediting',
        clicksToEdit: 1,
        listeners: {
          beforeedit: function (e, editor) {
            // disable the editor if this is the first row
            return editor.rowIdx !== 0
          }
        }
      }],
      viewConfig: {
        getRowClass: function (record, rowIndex) {
          // Adds a class only to the first row to add custom styling
          return rowIndex === 0 ? 'disabled-grid-row' : ''
        }
      }
    }
    I hope that helps.

  7. #6
    Sencha User
    Join Date
    Oct 2009
    Posts
    85
    Answers
    3

    Default

    the css for disabled-grid-row would be helpful

  8. #7
    Sencha Premium User tlloyduk's Avatar
    Join Date
    Sep 2010
    Posts
    91
    Answers
    1

    Default

    agreed, lol

  9. #8

    Default

    Quote Originally Posted by tlloyduk View Post
    agreed, lol
    The CSS just styles the row with a background colour afaik, simple stuff.

  10. #9
    Sencha Premium User tlloyduk's Avatar
    Join Date
    Sep 2010
    Posts
    91
    Answers
    1

    Default

    yeah, not really disabled tho, but fair enough for some things. I will figure out a different way for my use-case

  11. #10

    Default

    Quote Originally Posted by tlloyduk View Post
    yeah, not really disabled tho, but fair enough for some things. I will figure out a different way for my use-case
    Well as you can see in my previous snippet, I use the beforeedit listener to disable cell editing for a specific row.

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 5
    Last Post: 24 Jan 2012, 2:32 AM
  2. How to disable cell editing on Ext.grid.property.Grid?
    By ext-spring-mvc in forum Ext: Discussion
    Replies: 0
    Last Post: 30 Jun 2011, 7:12 AM
  3. Replies: 0
    Last Post: 27 Jun 2011, 11:23 PM

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
  •