We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

MVC Grid Json mode not working

Thread ID:

Created:

Updated:

Platform:

Replies:

90810 Oct 19,2009 06:15 PM UTC Jun 1,2012 07:27 AM UTC ASP.NET MVC (Classic) 5
loading
Tags: Grid
William B. Morrison
Asked On October 19, 2009 06:15 PM UTC

I've got the MVC grid working well in Server mode but can't get it to work properly in Json mode. Snippets of the code is below - note the Ajax Post near the end - that returns the data properly from the Action used as the paging Action so the data is coming back from the Controller just fine. When I use FireBug to debug it everything looks fine from a data standpoint. The problem is that when I click on a page number or any other element from the pager, I get the spinning circle that tells me that it's working but it never comes back from it. It appears that it should be caused by some missing JavaScript but I have everything referenced from the demo, I believe.

I couldn't get this to work properly using our infrastructure so I scaled back and used a simple model class and just return instances of it. I'm including:

- The test entity
- The controller
- The CSS and JavaScript references
- The Ajax post code showing that the data comes back from the controller properly
- The grid template from the view

I've looked at this next to the demo code that came with the MVC controls. I don't see anything that jumps out at me - I just want to know what would be causing the behavior noted (the spinning circle starts, the data comes back from the controller as noted in the debugger but the spinning circle never goes away). It is not a pause in the debugger as this happens whether or not I'm in IE and whether or not FireBug is active.

Thx in advance for any help you can give...

===================================================
public class TestEntity
{
public int Id { get; set; }
public string Name { get; set; }
}

===================================================
public class HelpDeskController : Controller
{
[RequiresDBSession]
public ActionResult Index()
{
GridPropertiesModel model = new GridPropertiesModel()
{
DataSource = GetInitialGridData(DatabaseSession),
Caption = "Test Entities",
PageSize = 10,
PageCount = 6,
JSONModePagingSortingMapper = "/Home/GridJSONAction",
ActionMode = "JSON",
ItemTemplate = "BrowseTemplate",
AllowPaging = true,
AllowSorting = false,
PrimaryKeyColumns = { "Id" },
HeaderText = { "Id", "Name"}
};
ViewData["GridModel"] = model;
return View();
}

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult GridJSONAction(PagingParams args)
{
List l = new List();
for (int i = 1; i <= 10; i++)
{
l.Add(new TestEntity() { Id = args.StartIndex + i, Name = "Name " + (args.StartIndex + i) });
}

return Json(l);
}

private List GetInitialGridData()
{
List l = new List();
for (int i = 0; i < 1000; i++)
{
l.Add(new TestEntity() { Id = i, Name = "Name " + i });
}
return l;
}
}

<%=Html.Grid("BrowseWorkOrdersGrid", "GridModel", column =>{
column.Add(p => p.Id);
column.Add(P => P.Name);
})
%>

===================================================
" rel="stylesheet" type="text/css" />
" rel="stylesheet" type="text/css" />






===================================================
$(document).ready(function() {

$.post("/Home/GridJSONAction", { StartIndex: "15" },
function(data) {
alert("Data Loaded: " + data);
});

});

===================================================









Balaji M [Syncfusion]
Replied On October 30, 2009 06:38 AM UTC

Hi William,

Sorry for the delay response.

I am afraid that I am unable to reproduce the reported issue. I have created a simple sample to test this issue and I am able to navigate the page the Grid in JSON MODE successfully and the sample is available from below link.

http://files.syncfusion.com/support/grid_mvc/Incidents/F90810/MVC_JSONGrid.zip

Please ensure the below details in your application,

1.Place the following three scripts files in separate folder under scripts folder.
* MicrosoftAjax.js,
* MicrosoftAjaxAdoNet.js,
* MicrosoftAjaxTemplates.js

Please have a look at the above sample and if still the issue exists, could you please try reproducing it in the above sample and send us the modified sample so that we could sort out the cause of the issue and provide you a solution?

Please let me know if you have any concerns.

Regards,
M. Balaji.

Praveen Matoria
Replied On May 30, 2012 07:10 AM UTC

Hello,

I think above mentioned link is dead: files.syncfusion.com/support/grid_mvc/Incidents/F90810/MVC_JSONGrid.zip

So, could you update the link or send me file at my email ID ASAP.

Basically, i require a MVC Grid with ActionMode = json.

Thanks

Bala Murugan A.S [Syncfusion]
Replied On May 31, 2012 05:09 AM UTC

Hi Praveen,

Thanks for using Syncfusion Products.

We have prepared a simple sample that demonstrate the JSON Mode in Syncfusion Essential Grid and the sample can be downloaded from the below link.

Sample:http://www.syncfusion.com/downloads/Support/DirectTrac/94967/JSONGrid1697401803.zip

To know more about the JSON Mode please refer the below links:

Documentaion link:
http://help.syncfusion.com/UG/User%20Interface/ASP.NET%20MVC/Grid/documents/jsonmode.htm

Online Samples:

Editing: http://mvc.syncfusion.com/sfmvcsamplebrowser/10.2.0.56/Grid_MVC/Samples/4.0/Razor/Editing/JSONCRUD

Paging:
http://mvc.syncfusion.com/sfmvcsamplebrowser/10.2.0.56/Grid_MVC/Samples/4.0/Razor/Paging/JsonPaging

Sorting:
http://mvc.syncfusion.com/sfmvcsamplebrowser/10.2.0.56/Grid_MVC/Samples/4.0/Razor/Sorting/JsonSorting

Grouping:
http://mvc.syncfusion.com/sfmvcsamplebrowser/10.2.0.56/Grid_MVC/Samples/4.0/Razor/Grouping/JSONGrouping

Filtering:
http://mvc.syncfusion.com/sfmvcsamplebrowser/10.2.0.56/Grid_MVC/Samples/4.0/Razor/Filtering/JsonFiltering

Please try the above sample and let us know if you have any concerns.

Regards,
Bala Murugan A.S


Praveen Matoria
Replied On May 31, 2012 10:46 AM UTC

I got it working. The was that the latest build has some issue with DLL's. So, JSON mode was not working with it. My Team  had older version of it and it worked with it. Please verify that your latest Grid DLL's works fine with ActionMode="JSON"

Bala Murugan A.S [Syncfusion]
Replied On June 1, 2012 07:27 AM UTC

Hi Praveen,

Thanks for your update.

The ActionMode property has been changed from a string to an ActionMode enum in the  version 9.1 and later version. Please refer the release notes from the below link.

http://files2.syncfusion.com/Installs/v9.1.0.20/ReleaseNotes/UI.html#ASPNET-MVC-Grid

Please have a look at the release notes and let us know if you have any concerns.

Regards,
Bala Murugan A.S

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;