How to create an onclick method for rows selection and pass row data to another controller

Hello

I want my grid rows to be clickable and in the onclick event, I want to pass the data from the row to another controller. The click event should be a double click or a long press action.

Following this answer from StackOverflow, I could do it using the RowSelected client event. I could get the row values from args, and then create an object from them for passing it to another controller using jQuery Ajax. But then again, I need to do this via double click of the row or a long press.

That should do it. My question is: Is this the way to go? Syncfusion has any example in the documentation that shows how to code this behavior?

Thank you

2 Replies

SO Samuel Otero April 9, 2018 05:38 PM UTC

I found this thread. That should help, but what about if the controller that I want to call is an HttpPost? How is the correct Ajax call written in order to call a controller that redirects the user to another page?


VN Vignesh Natarajan Syncfusion Team April 11, 2018 02:54 PM UTC

Hi Samuel, 
 
Thanks for using Syncfusion support.  
 
We have analyzed your query and we suspect that you want to send selected Row data on the double click on to another view page and perform editing in it and on clicking save values must be updated in data base. 
 
We have achieved your requirement using ActionBegin event of the grid when request Type is editing, Ajax post is sent to the another controller (GridEdit in our sample) which has two view pages for Create and Edit actions.  
 
Refer the below code snippet 
 
         }) 
                    .ClientSideEvents(e=>e.ActionBegin("Begin").QueryCellInfo("cellInfo")) 
) 
<script type="text/javascript">    
    function Begin(args) { 
        var type = args.requestType; 
        if (type == "beginedit" || type == "add") { 
            args.cancel = true; 
            if (!ej.isNullOrUndefined(args.rowIndex)) 
                var OrderID = this.model.currentViewData[args.rowIndex]["OrderID"]; 
            this.element.ejWaitingPopup("show"); 
            if (type == "beginedit") 
                var url = "/GridEdit/Edit?OrderID=" + OrderID; 
            else 
                var url = "/GridEdit/Create"; 
            location.assign(url); 
        } 
    }    
</script> 
 
Refer the below screenshot for the output (edit action another view) 
 
 
 
 
We have prepared a sample as per your requirement which can be downloaded from below link 
 
 
 
 
If we misunderstood your query please get back to us with more details. 
 
Regards, 
Vignesh Natarajan 
 
 


Loader.
Up arrow icon