Domanda

I have a web application in MVC3 and i'm using Telerik Grid Batch Editing.

Batch Editing have save changes button which returns UPDATED COLUMNS to controller IEnumerable list like

    [GridAction]
    public ActionResult Update(IEnumerable<Customers> updated)
    {
        ///user codes
    }

but how to collect updated rows and make array send like IEnumerable list from Javascript with ajax to Controller ?

EDIT I'm putting my view png

enter image description here

I just want to send updated rows data to Controller and Save Changes button can do this but before thje send values i just want to ask to user "Are you sure to Load?" and after the send data I want to refresh all the page

So i thinked to do this with ajax request because i'm also using batch editing with ajax requests

Do you have any exprience for this situation?

È stato utile?

Soluzione

Use the AJAX POST as I have used in my Tested Javascript function as::

function TestAjax() {
    var Test = [];

    for (var i = 0; i < 5; i++) {
        Test.push({ ID: i, Name: "RJ" });
    }

    $.ajax({
        type: 'POST',
        url: rootUrl('Home/TestPost'),
        contentType: "application/json",
        //data: { Test: JSON.stringify( data) },
        data:JSON.stringify( {Test: Test}),
        success: function (data) {
            alert("Succeded");
        }
    });
}

And on Server Side(i.e. In Controller) use something Like::

public ActionResult TestPost(IEnumerable<TestViewModel> Test)
    {
        return Json(3);
    }

The ViewModel Contains different propeties which are of different datatypes as::

public class TestViewModel
    {
        public long ID { get; set; }
        public string Name { get; set; }
    }

This is working fine. May be this will help you.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top