Quantcast
Channel: Recent Discussions — DataTables forums
Viewing all articles
Browse latest Browse all 82029

Datatable editor posting to db

$
0
0

Hello all!

I have the editor extension to my datatable. When a cell is changed I want the value to be sent to a service --> controller --> repository and then be updated via an SP.

Columns in db are, Dog, Cat, Fish, Cow.

JS:

 $(document).ready(function () {
                editor = new $.fn.dataTable.Editor( {
                    ajax: {
                        url: "Services/FileName.svc/SaveNewAnimals ",
                        contentType: 'text/javascript; charset=utf-8',
                        dataType: 'json',
                        data: function(d){
                        
                           return JSON.stringify(d.data);
                       },
                    },

d.data will no contain the value that has been changed in the table. For example lets say we change a 1 --> 2.
d.data will look like this: 17058: {Cow: "2"} - if you change a cell in the cow column. Also the number 17058 I have no idea what that is.

Service (c#):

 public propertyClass SaveNewAnimals (arg) 
        {

            var response = new AnimalPropertys
            {
                Cow = arg.Cow
            };
            Controller.AnimalMethodInController(response);
            return response;
        }

The problem is the **argument **in the service. When I POST from js --> service and send the data 17058: {Cow: "2"} I dont know how to retrieve it with an argument. Shall I create a property class for the send POST and map the values with the properties. Or can I simply send a int from the POST?

What is the best way to retrieve the POST data in a method? Which datatype can I put as and argument to retrieve the data being send from POST.

Br,

Anton


Viewing all articles
Browse latest Browse all 82029

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>