This is a migrated thread and some comments may be shown as answers.

Sending Grid Data to database.

1 Answer 207 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Alex
Top achievements
Rank 1
Alex asked on 06 Jun 2014, 06:05 PM
Hi, 

I want to send data from the Kendo Grid to a database. however, i dont want to send it directly, i want it to go through a c# method I have, before sending. 

I got it to the point where it calls the c# code inside of the controller. However, it isn't sending the data I have synced to the button.

here's the code.
@(Html.Kendo().Button()
        .Name("SentItems")
        .Content("Send Products")
        .Events(e => e.Click("SendData")))
 
 
function SendData()
    {
        alert('Sending Data');
        var gridData = $("#PLAGridMain").data("kendoGrid");
        var text = "Object properties are: ";
 
        $.ajax({
            url: '/Home/sendRows',
            cache: false,
            type: 'POST',
            contentType: 'application/json; charset=utf-8',
            data: JSON.stringify($("#PLAGridMain").data("kendoGrid").dataSource),
 
            complete: function()
        {
                alert("success: ");
        }
        })
    }
 
 
 
C# in HomeController:
 
[HttpPost]
        public void sendRows(Grid<string>)
        {
            //[DataSourceRequest] DataSourceRequest dataSourceRequest
            //send each row to the google MCC.
            string PLA = string.Empty;
        }

1 Answer, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 10 Jun 2014, 11:49 AM
Hi Alex,

I would recommend using the Grid's built-in CRUD functionality, which is covered in the following articles:
Then, once the button is clicked you can call the Grid's saveChanges method, thus sending all unsaved changes to the specified Controller method.

Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Alex
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Share this question
or