I really need some help here.
I'm using MVC3 with Visual Studio 2010. with jquery 1.6.2 AND jquery-ui 1.8.14.
I have a jQuery grid on a view that will not show data even though I've verified that I'm getting data back from the database.
The grid is set up very simply (no features). It's using a datasourceURL to retrieve the data and the corresponding action is getting. When I return the view, I've tried passing in the ObjectResult (no data displayed, no errors). I've tried passing in an IQueryable, but this gives me an error in the javascript (1.6.2) that says "Microsoft JScript runtime error: The remote request to fetch data has failed: (error) undefined". This error is thrown at the point where I'm returning the view for the grid request.
If I set up a grid with the exact same parameters, but use the columns set in the demo project "Taz" created, and even use the same dataSourceURL, but change the returned data to be the auto-generated 1000 records of accounts, it works fine.
What am I missing?
Thanks,
Tony
Hi,
Could you try with jQuery 1.5 or 1.4.4 ? Several things have been broken recently in jQuery with respect to $.ajax functionality.
I doublt this is related to an issue in your MVC code.
Let me know if that works.
Angel
Hi again Tony,
our team has checked several of the MVC samples browser samples on 1.6.2, and they work fine, so it looks like the jQuery version is maybe not the issue in your case.
to isolate further the issue, i suggest you run the MVC Samples browser, and compare the view / controller definitions with your own project.
At best, some sample code snippet that you have would be of great help to us.
Thank you
Hi Tony,
I ran your sample and managed to reproduce the issue you're experiencing. Basically there wasn't any data coming from the server to the client. You need to replace this line in the controller:
return Json(Models.AccountModels.GetAccountList(), JsonRequestBehavior.AllowGet);
with this one:
return View(Models.AccountModels.GetAccountList().AsQueryable<BankAccount>());
The grid automatically resolves this and sends JSON in the response instead of HTML data. That's because of the [GridDataSourceAction] attribute, which serves as a kind of data filter.
You can still just return Json(..) but this would mean you cannot take advantage of paging, sorting, filtering, etc., because there won't be any filter to intercept and process that . (Also in the latter case ResponseDataKey would need to be set to "" because all records would be automatically serialized in the root of the response by the MVC JSON Serializer).
By changing the above, the sample should work fine. One thing i noticed is that with the ig.uimin.js file you have referenced in the sample app, there are issues with jQuery 1.6.2. I tried replacing this reference with the latest IG code, and it seems to work fine. In the meantime i suggest to reference jQuery 1.4.4 or make sure the ig.ui.js is coming from the latest official build.
Thank you, and hope it helps,
Here's something interesting, though I'm not sure what to make of it.
I created a third table in the database and added some data. This new table has no relationships in the database. When I added a new grid, using the new datatable through entity framework, it works the way I would expect it to; the data shows up in the grid with NO errors.
The data from tables that have a relationship, however, fails with the initial error: The remote request to fetch data has failed.
Any ideas now? I can upload a new demo if it helps. Just let me know.
Hello Anthony ,
Please let us know if Angel's suggestion helped you resolve the issue.
Feel free to ask id you need further assistance regarding this.
I'm about to just give up on the whole thing. This has been extremely frustrating.
I can get it to work IF i first iterate through the results putting them into a list and then pass the list to the view. Like this:
var AccountList = from a in db.GetAccountList(bkNum, Serv) select a; List<Account> MyAccountList = new List<Account>(); foreach (Account item in AccountList) { MyAccountList.Add(item); } return View(MyAccountList.AsQueryable<Account>());
IF I do this, it fails:
var AccountList = from a in db.GetBankAccountList(202, 2) select a; return View(AccountList.AsQueryable<Account>());
Also, IF, as in the first example, there are no records in the database, it fails with the same error.
Thoughts?
sorry to hear that you are having troubles with this. The no records issue is something that we got reported a while ago, and fixed. I am sure if you get the first service release build you won't be experiencing this any more. Regarding the difference between the two code statements above, it kind of looks pretty identical to me, but i will have a deeper look and follow up.
Ok, I'll work around the empty result issue. I'm also having to cast to a generic list for results to show up, but i can live with that. This product isn't going live until the end of the year so I look forward to seeing some issues resolved before then.
Thanks for the help.
Hello,
Here is the latest internal build.
hi,
the issue about the exception when there are no records in teh underlying datasource is not related to the jquery version (it's part of the server-side logic). That's fixed but it's not available in the first service release build. I am sure our development support team will be able to provide you with the internal build which has this fix as well.
Thank you,
Hello Tony,
Thank you for the fast update.
You are correct , the version of the jQuery the cause.
The first service release of the toolset is not officially tested with the 1.6.2 version
If you use v 1.4.4 for example you won't experience the issue.
ok, installed the service release and updated my project.
However, I'm still getting the error for an empty result set (List<Account).
I updated the scripts, CSS, and the Infragistics.Web.Mvc.dll
Maybe it's the scripts?
<script src="@Url.Content("~/Scripts/jquery-1.6.2.min.js")" type="text/javascript"></script> <script src="@Url.Content("~/Scripts/jquery-1.8.14.min.js")" type="text/javascript"></script> <script src="@Url.Content("~/Scripts/json2.js")" type="text/javascript"></script> <script src="@Url.Content("~/Scripts/jquery-ui.min.js")" type="text/javascript"></script> <script src="@Url.Content("~/Scripts/jquery.tmpl.js")" type="text/javascript"></script> <script src="@Url.Content("~/Scripts/ig.ui.min.js")" type="text/javascript"></script> <script src="@Url.Content("~/Scripts/ig.ui.grid.min.js")" type="text/javascript"></script> <script src="@Url.Content("~/Scripts/ig.ui.editors.min.js")" type="text/javascript"></script>
The error is in jquery-1.6.2.js
The message is: Microsoft JScript runtime error: The remote request to fetch data has failed: (error) undefined
If there are records in the database, then I don't get the error.