Results 1 to 4 of 4

Thread: How to check if a grid row (any row) is selected??

  1. #1
    Sencha User
    Join Date
    Dec 2013
    Posts
    52
    Answers
    1

    Default Answered: How to check if a grid row (any row) is selected??

    Not which row is selected, but if any row in general is selected. I have a delete button on grid tbar which uses SelectionModel(). But in the event user launches grid and clicks delete button, this will throw an error since no record(row) is selected. So maybe I can check to see if a row is selected and only then enable the delete button or something. Normally would be no biggie but this will be going in to testing phase soon.

    Need a quick response, thanks!

  2. ON your question "So maybe I can check to see if a row is selected and only then enable the delete button or something."You can check of there is a selection my doing the following:
    Code:
    var checkedRows = yourgrid.getSelectionModel().getSelection();
    if (checkedRows.length > 0) button.enable; 
    // ...

  3. #2
    Sencha Premium User
    Join Date
    Feb 2011
    Location
    NJ
    Posts
    337
    Answers
    62

    Default

    You can add a selectionchange listener to your grid and then set the button to be enabled/disabled based on the selections in the grid. The second parameter will be an array of all the selected records.

    See http://docs.sencha.com/extjs/4.2.2/#...electionchange

  4. #3
    Sencha User
    Join Date
    May 2013
    Posts
    28
    Answers
    3

    Default

    ON your question "So maybe I can check to see if a row is selected and only then enable the delete button or something."You can check of there is a selection my doing the following:
    Code:
    var checkedRows = yourgrid.getSelectionModel().getSelection();
    if (checkedRows.length > 0) button.enable; 
    // ...

  5. #4
    Sencha User
    Join Date
    Dec 2013
    Posts
    52
    Answers
    1

    Default

    both examples worked great! i knew it was an easy solution but just could not seem to get it right. I chose the 2nd way because its more simple and clean. thanks again for quick replies!

Posting Permissions

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