Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
20
POST AXJX calling flinging in Infragistics.Web.Mvc
posted

Model:

public class Product
{
public int ProductID { get; set; }
public string Name { get; set; }
public string ProductNumber { get; set; }

public List<ProductLocations> Locations { get; set; }
}

public class ProductLocations
{
public string Address { get; set; }
}

Controller 

[GridDataSourceAction]
[HttpPost]
public ActionResult PostDataMethod3(Product Param1, string Param2, string Param3)
{
try
{
List<Product> products = new List<Product>();

products.Add(new Product { ProductID = 1, Name = "Product 1", ProductNumber = "12345" });
products.Add(new Product { ProductID = 2, Name = "Product 2", ProductNumber = "12346" });
products.Add(new Product { ProductID = 3, Name = "Product 3", ProductNumber = "12347" });
products.Add(new Product { ProductID = 4, Name = "Product 4", ProductNumber = "12348" });
products.Add(new Product { ProductID = 5, Name = "Product 5", ProductNumber = "12349" });

return View(products.AsQueryable());
}
catch (Exception ex)
{
string error = ex.Message;
return null;
}

}

AJAX call

var appJson = {
"Param1": { "ProductID": 1, "Name": "test product", "ProductNumber": "P123", "Locations": [{ "Address": "Address1" }, { "Address": "Address2" }]}, "Param2": "Param2", "Param3": "Param3" };

$('#postData3').click(function (e) {
e.preventDefault();

$.ajax({
url: '@(Url.Action("PostDataMethod3"))',
type: 'POST',
traditional: true,
contentType: "application/json",
dataType: "json",
data: JSON.stringify(appJson),
success: function (response) {
alert('Succcess');
$('#grid').igGrid({ dataSource: response }).igGrid("dataBind");
},
error: function (xhr, ajaxOptions, thrownError) {
alert('Failure - ' + xhr.responseText);
$('#grid').igGrid({ dataSource: null }).igGrid("dataBind");
}
});
});

Eroor:

2022infragisticerror.igGridQueryStringToJson.zip

Parents Reply Children
No Data