Skip to content

Instantly share code, notes, and snippets.

@yuristrelets
Last active December 21, 2017 18:07
Show Gist options
  • Save yuristrelets/d88abca500199cff1b50 to your computer and use it in GitHub Desktop.
Save yuristrelets/d88abca500199cff1b50 to your computer and use it in GitHub Desktop.
Get selected record in ExtJS 4.2.1
getSelectedRecord: function() {
var grid = this.getGrid(),
records = grid.getSelectionModel().getSelection(),
record;
if(records.length) {
// get first record from selection
record = records[0];
// find selection record in store
record = grid.getStore().getById(record.getId());
if(record) return record;
}
return false;
}
@smanunta
Copy link

smanunta commented Dec 21, 2017

very helpful.

I would add that this could be modified a bit to handle multiple selections by throwing in a forEach loop with the selection.

`if(records.length) {

records.forEach(function(record)
    // full record = record
    // record.getData() will return the record data
    // record.getData().DATA_NAME will return the specific item in the data youre looking for
);

}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment