Using getSelectedRows data

I'm trying to use the best practice method of using the getSelectedRows for the DataGrid.  I have a CheckBox column and when I check the box I can call a button click event 

  let selectedRows = this.$refs.gridDialog.getSelectedRows();
  console.log(JSON.stringify(selectedRows))
  alert(selectedRows.length)
The selectedRows length is correct but the JSON object is empty.  I'm getting that from your example at  Vue Template - CodeSandbox   If I don't use the JSON stringify I get a very complicated object:

(3) [tr.e-row, tr.e-row.e-altrow, tr.e-row]0: tr.e-rowaccessKey: ""align: ""ariaAtomic: nullariaAutoComplete: nullariaBusy: nullariaChecked: nullariaColCount: nullariaColIndex: nullariaColSpan: nullariaCurrent: nullariaDescription: nullariaDisabled: nullariaExpanded: nullariaHasPopup: nullariaHidden: nullariaKeyShortcuts: nullariaLabel: nullariaLevel: nullariaLive: nullariaModal: nullariaMultiLine: nullariaMultiSelectable: nullariaOrientation: nullariaPlaceholder:

If I use just a standard single row select the properties are clean and exact

this.selectedPI = arg["data"]["last_name"] + ", " + arg["data"]["first_name"],

If these are 2 columns in my grid

 <e-column field="appl_id" headerText="App ID" width="125" :visible="false"></e-column>

 <e-column field="subproject_id" headerText="Sub Project" width="90" ></e-column>

What's the best way to loop the selected rows and read the field data?

Thanks





1 Reply

PS Pavithra Subramaniyam Syncfusion Team April 21, 2022 01:21 PM UTC

Hi William,


Thanks for contacting Syncfusion support.


From your query, we understood that you want to loop the selected records inside a button click. Since you are using the getSelectedRows method, it will only return the selected row element and while stringifying the element arrays the JSON will be empty. So, we suggest the use of “getSelectedRecords” method which will return the array of selected row data instead of getSelectedRows method. Please refer to the below API link for more information.


https://ej2.syncfusion.com/vue/documentation/api/grid/#getselectedrecords


Regards,

Pavithra S


Loader.
Up arrow icon