Copy row in context menu

Hello,

how can i copy a row using the context menu

--> i could not find the primaryID with javascript

Thanks Jens

My code:

aspx
...
ClientSideEvents ContextClick="ContentClick"  />
                    
                        
                            
                        

                    

...


js

    function ContentClick(args) {

                 alert("Hi");

            var kbnUrl = "default9.aspx/CopyAction"

            var card = {

                "PrimaryID": ????    <--  i cant get die Primary ID form the Row   
            };

            $.ajax({
                async: true,
                type: "POST",
                contentType: "application/json; charset=utf-8",
                url: kbnUrl,
                data: JSON.stringify(card),
                dataType: "json",
                success: function (res) {
                  
                     alert("Prima!");

                },
                error: function (e) {
                     alert("error");
                }
            });


        }


C#

 [WebMethod]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public static object CopyAction(int PrimaryID)
    {
        SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString());
        if (myConnection.State == ConnectionState.Closed)
        {
            myConnection.Open();
        }

        string updateQuery = "INSERT ... into ... WHERE tableID = PrimaryID";
        SqlCommand UpdateCmd = new SqlCommand(updateQuery, myConnection);


        UpdateCmd.Parameters.Add(new SqlParameter("@PrimaryID", SqlDbType.Int)).Value = PrimaryID;

        UpdateCmd.ExecuteNonQuery();
        var ID = PrimaryID;
        return PrimaryID;
    

    }


2 Replies

JK Jens Kugler February 13, 2018 09:09 AM UTC

Problem solved

 var strTEST = args.model.selectedRecords[0].EmployeeID;
var card = {

                "PrimaryID": strTEST   
            };

...


RS Renjith Singh Rajendran Syncfusion Team February 13, 2018 09:58 AM UTC

Hi Jens, 

Thanks for the update. 

We are happy to hear that you requirement has been achieved. 

Please get back to us if you need further assistance. 

Regards, 
Renjith Singh Rajendran. 


Loader.
Up arrow icon