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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Call rowSelected programmatically

Thread ID:

Created:

Updated:

Platform:

Replies:

145325 Jun 17,2019 08:06 PM UTC Jun 20,2019 05:16 AM UTC Vue 5
loading
Tags: Data Grid
William Morgenweck
Asked On June 17, 2019 08:06 PM UTC

Current when an end user selects a row the row argument are passed to the function.  How can I call the rowSelected method via a function. If a row is selected I need to pass the arguments to another function. If no row is selected it needs to terminate. 

Pavithra Subramaniyam [Syncfusion]
Replied On June 18, 2019 06:56 AM UTC

Hi William, 

Thanks for contacting Syncfusion support. 

First of all, we would like to inform that we could not understood your query properly. But we suspect that you want to pass the selected row details to your own function. So, we suggest to use Grid getSelectedRows (to get the selected row elements), getSelectedRecords (to get the selected records detail), getSelectedRowIndexes (to get the selected rows index details) and getSelectedRowCellIndexes (to get the selected cell index details) to collect the required details and then you can pass the collected details to your own function. 

Documentation Links for above mentioned Grid methods, 







If we misunderstood your query, please share more details about your requirement with the Grid code snippet. This will help us to provide the better solution for your requirement as early as possible. 
 
Regards, 
Pavithra S. 


William Morgenweck
Replied On June 18, 2019 01:46 PM UTC

sorry about that.

the grid has:
                 <ejs-grid
                  id="memberGrid"
                  ref="grid"
                  :dataSource="topGridContent"
                  :rowSelected="memberRowSelected"
                  :allowSorting="true"
                  :recordDoubleClick="membersDoubleClick"
                  :selectionSettings="selectOptions"
                >

and when the memberRowSelected function is called it is passed arguments.  so

 memberRowSelected: function(args) {
      let record = args.data;
     this.displayName =
      " for " +
        record["First_Name"] +
        " " +
        record["Middle_Initial"].substring(0, 1) +
        " " +
        record["Last_Name"];

//calls an external function and passes all of the args
}

I want to have a button than when clicked will call memberRowSelected and pass the same args as the grid does when a row is selected. It needs to be formatted as the args not a group of different elements so that the function on;y needs to be written one way.



Pavithra Subramaniyam [Syncfusion]
Replied On June 19, 2019 12:11 PM UTC

Hi William, 

Thanks for the update. 

The Grid rowSelected event only invoke when we select the row in Grid and we have formed this rowSelected event arguments in our source level. So, we cannot form this argument in client side while we programmatically call this rowSelected event. So, we suggest to store this event arguments in one global variable at initial triggering and then you can pass this stored arguments while calling this rowSelected event programmatically. Please refer the following code snippet, 

<script> 
import Vue from "vue"; 
import { 
  GridPlugin, 
  Page 
} from "@syncfusion/ej2-vue-grids"; 
import { ButtonPlugin } from "@syncfusion/ej2-vue-buttons"; 
import { data } from "./datasource"; 
 
Vue.use(GridPlugin); 
Vue.use(ButtonPlugin); 
 
var argsValue; // Global variable 
 
export default { 
  data() { 
    return { 
      data: data 
    }; 
  }, 
  provide: { 
    grid: [Page] 
  }, 
  methods: { 
    memberRowSelected: function(args) { // RowSelected event 
      argsValue = args; // Stored the rowSelected event aruguments in global variable  
    }, 
    btnClick: function(e){ 
        this.memberRowSelected(argsValue); // Passed the global variable value to rowSelected (i.e memberRowSelected) method 
    } 
  } 
}; 
</script> 

 
Regards, 
Pavithra S. 


William Morgenweck
Replied On June 19, 2019 03:07 PM UTC

That will work-- thanks

Pavithra Subramaniyam [Syncfusion]
Replied On June 20, 2019 05:16 AM UTC

Hi William,  

Thanks for your update. 

Please contact us if you need any further assistance. As always, we will be happy to assist you.  

Regards,  
Pavithra S. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon