Unable to get row index using commandClick

Hi Team,

I am required to show line item in pop-up dialog box. I am unable to get row index of the grid in commandClick.

<ejs-grid
          ref="SO_lineItem_Grid"
          :allowResizing="true"
          :showColumnChooser="true"
          rowHeight="40"
          :dataSource="dataGrid"
          :commandClick="commandClick"
        >
          <e-columns>
            <e-column headerText="Actions" width="140" :commands="commands" textAlign="left"></e-column>


commands in data() property

commands: [
        { type: 'Edit'buttonOption: { iconCss: 'e-icons e-edit'cssClass: 'e-flat' } },
        { type: 'Delete'buttonOption: { iconCss: 'e-icons e-delete'cssClass: 'e-flat' } },
        { type: 'Save'buttonOption: { iconCss: 'e-icons e-update'cssClass: 'e-flat' } },
        { type: 'Cancel'buttonOption: { iconCss: 'e-icons e-cancel-icon'cssClass: 'e-flat' } },
        { type: 'View'buttonOption: { iconCss: 'fa fa-eye'cssClass: 'e-flat' } }
      ],


commandClick method. Unable to get rowIndex when clicking same row for second time

commandClick: function(args) {
      console.log('commandClick'args)
      if (args.commandColumn && args.commandColumn.type === 'View') {
        let selectedrowindex = this.$refs.SO_lineItem_Grid.getSelectedRowIndexes() // Get the selected row indexes.
        alert(selectedrowindex)
      }
    }


Grid with commandClick


Thanks & Regards,
Sandeep G



3 Replies 1 reply marked as answer

PG Praveenkumar Gajendiran Syncfusion Team September 15, 2021 11:38 AM UTC

Hi Sandeep, 
Thanks for contacting Syncfusion support. 
We checked your query and provided information, based on that we have prepared a sample and checked your reported issue, but we are not able to reproduce your reported problem and  getSelectedRowIndexes method working properly at our end. Please check the below sample and screenshot for your reference.

Sample: https://codesandbox.io/s/vue-template-forked-p6h5b?file=/src/App.vue
 
Screenshot:
 

Alternatively, we suggest you to use the getRowInfo method to get a row information based on a target cell element as demonstrated in the below code snippet. 
commandClick: function (args) { 
      var rowInfo = this.$refs.grid.ej2Instances.getRowInfo(args.target); 
      console.log( rowInfo); 
      alert("SelectedRowIndexes:" + rowInfo.rowIndex); 
    }, 
 
 
 
API Link: https://ej2.syncfusion.com/vue/documentation/api/grid/#getrowinfo

Still if you are facing the issue, please share the below details to validate further at our end.
 
  
  1. Syncfusion package version used.
  2. Let us know the replication procedure for reproducing the problem.
  3. If possible share us a simple sample to replicate the problem or try reproducing it in the above provided sample. It would be helpful to identify your problem case better so that we can check and provide the solution based on that
  
Please get back to us with the requested details which will be helpful for us to understand your problem at our end and provide the solution as early as possible 
  
Regards 
Praveenkumar G 


Marked as answer

SG Sandeep G September 17, 2021 04:53 AM UTC

Hi PraveenKumar,


this.$refs.grid.ej2Instances.getRowInfo(args.target); works fine, where as getSelectedRowIndexes method return empty array when row selected se.

Thanks for your reply

Regards,
Sandeep G



PG Praveenkumar Gajendiran Syncfusion Team September 20, 2021 01:36 PM UTC

Hi Sandeep, 
Thanks for your update. 
Based on your query, we have prepared a sample and checked your reported issue again, but we are not able to reproduce your reported problem and the getSelectedRowIndexes method working properly at our end. Please check the below sample and screenshot for your reference.

Sample: https://codesandbox.io/s/vue-template-forked-k178s?file=/src/App.vue
 
Screenshot:
 

So please share the below details to validate further at our end
, 
  
  1. Syncfusion package version used.
  2. Let us know the replication procedure for reproducing the problem.
  3. If possible share us a simple sample to replicate the problem or try reproducing it in the above provided sample. It would be helpful to identify your problem case better so that we can check and provide the solution based on that.
   
Regards 
Praveenkumar G 


Loader.
Up arrow icon