I have This code in a C# MVC 4 VS2012 project. I need to be able to update the shopping cart using jSON data with JQuery/AJAX, i'm using jqGrid to display the data and pulling the shopping cart items from SQL. I'm new ASP.NET MVC 4 and am having some difficulties incorporating AJAX, jSON, and jqGrid into the mix.
I've searched Google and I'm not understanding how to do this - I see many solutions using PHP and ASPX, but i'm not sure how to translate these to my C#/MVC 4 project. I've read the documentation for Ajax and tried a few things such as @ajax.actionlink and new AjaxOptions { UpdateTargetId = myDivIneedToUpdate} but i'm not sure how to implement these into the MVC solution.
If someone could point me in the right direction I would appreciate it. All of my code is on github at the link above - or github , user=jbeans99 , repo= MVC4_OSU_SportStore....
Thanks in advance!
Also, I believe I should be returning partial views in my controller as I just want the page to refresh the data for the category the user chooses; just haven't got to that part yet.
// I think I should be returning a partial view here [HttpGet] publicActionResultChess() { returnView(); }
[HttpPost] publicActionResultGetAllProducts(JqGridSettings gridSettings) { int totalPages; int totalRecords; var allProducts =DatabaseDAL.GetAllProductModels();
var results = jqGridDataManager.GetGridData<ProductModel>(gridSettings, allProducts, out totalPages, out totalRecords); JqGridResult result =newJqGridResult() { Page= gridSettings.PageIndex, Records= totalRecords, Total= totalPages, Rows= results.ToList() };
[HttpPost] publicActionResultGetChessProducts(JqGridSettings gridSettings) { int totalPages; int totalRecords; var allProducts =DatabaseDAL.GetChessProductModels();
var results = jqGridDataManager.GetGridData<ProductModel>(gridSettings, allProducts, out totalPages, out totalRecords); JqGridResult result =newJqGridResult() { Page= gridSettings.PageIndex, Records= totalRecords, Total= totalPages, Rows= results.ToList() };
Replies
Know the answer? Post it — somebody with the same question will find it here.