0

Sorry for the odd question name folks, I'm not sure I properly know how to phrase this question, but I am working with javascript, and would like to reference an objects member, but abstractly by string, is this possible in JavaScript? (or any language for that matter?) eg,..

The MemberName is determined when the function is run, could be 'Product Code' for example, but selected row will always represent a selected row in a grid. is this even possible? I am trying to create a generic function which will allow me to pass any grid to it, with the name of the column i want the value from - if that helps.

function GetSpecificColumnFromSelectedRow(SelectedRow, MemberName) {
    return SelectedRow.MemberName; 
}
Spades
  • 73
  • 2
  • 9

1 Answers1

2

It's rather easy:

SelectedRow[MemberName]

And you don't need a function to do it, which is why I didnt include your original function wrapper.

Joseph Dailey
  • 4,735
  • 2
  • 15
  • 18