We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Select Row dynamically

I have a grid with the following information:
                 <ejs-grid
                  id="reportGrid"
                  ref="reportGrid"
                  :allowSelection="true"
                  :dataSource="articles"
                  :rowSelected="onRowSelectedPubs"
                  :toolbar="toolbarOptions"
                  :allowTextWrap="true"
                  :allowExcelExport="true"
                  :allowPdfExport="true"
                  :recordDoubleClick="pubDoubleClick"
                  :selectionSettings="selectOptions"
                  :toolbarClick="toolbarClick"
                >
And I need to select a row via code.  I have tried

               var obj = $("#reportGrid").data("ejs-grid");
                obj.selectRow(5, true);

and 

              

this.$refs.reportGrid.selectRow(0);

the information  at 
https://ej2.syncfusion.com/vue/documentation/api/grid/?_ga=2.115438726.1453351565.1573582025-616283409.1556326607#selectrows 

does not give very much help





1 Reply

PS Pavithra Subramaniyam Syncfusion Team November 14, 2019 06:52 AM UTC

Hi William, 
 
Thanks for contacting Syncfusion support. 
 
We have checked your code and to access the Grid methods in Vue you can use the reference as given below. Please refer to the below code example and sample link for more information. 
 
In the below sample we have selected the row in a button click event which is working fine at our end. 
 
[App.Vue] 
<template> 
  <div id="app"> 
    <ejs-button id="enable" cssClass="e-flat" @click.native="enable">Select</ejs-button> 
    <ejs-grid 
      id="reportGrid" 
      ref="reportGrid" 
      :actionFailure="fail" 
      :allowSelection="true" 
      :dataSource="data" 
      :allowTextWrap="true" 
      :allowExcelExport="true" 
      :allowPdfExport="true" 
      :selectionSettings="selectOptions" 
    > 
      <e-columns> 
       .   .   . 
      </e-columns> 
    </ejs-grid> 
  </div> 
</template> 
 
<script> 
.   .   . 
export default { 
  data() { 
    return { 
      data: data, 
      selectOptions: { type: "Single" } 
    }; 
  }, 
  methods: { 
    fail: e => { 
      debugger; 
    }, 
    enable: function() { 
      this.$refs.reportGrid.ej2Instances.selectRow(5true); 
    } 
  } 
}; 
</script> 
 
 
If you are still facing the issue please provide the below details that will be helpful for us to provide a better solution as early as possible.  
 
  1. Share the full code related to Grid
  2. Share the Syncfusion version
  3. Share the stack trace if any
  4. Please reproduce the issue in the above sample if possible.
 
Regards, 
Pavithra S.  


Loader.
Live Chat Icon For mobile
Up arrow icon