Forum
10:06
29/08/2008
I am having issues using JQGrid and MVC framework. IF I have an application with no application name everything works fine. For example, if my url is http://localhost/Home/Example, everything is fine.
However, if my application has an application name http://localhost/myapp/Home/Example the url does not work. It does not take into accout the application name.
I have tried many variations of the url, /Home/Example, /../Home/Example, ~/Home/Example. It does not see the application name. Are my routes incorrect? I am just using the default route when you created an MVC application.
11:43
Moderators
30/10/2007
Also if possible check the paths to js files. You need to ajust this
in the loader.
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Good question. Mvc will support any path you thorw at it as long as it's pattern is mapped in the route dictionary. For example in my case I have such a big Mvc app I decided to create sub-folders for my controllers. Remember, the Mvc routingengine abstracts the folder structure you have so you don't have to reveal your folder structure in your url. I have an Account folder with an AccountController, AccountSummaryController, etc. So my url would look like /Account/Account/GetMyDataById/101, but it doesn't, it only shows /Account/GetMyDataById/101.
If you do not specifcy the "/" in front of the Account in your url in your ajax call, the routing engine will prefix your url with the current url, so you will get something like /Account/GetMyDataById/Account/GetMyDataById/101. So make sure you prefix url with an "/" and include the controller: "/Account/GetMyDataById".
Just as an example my route map looks like this:
routes.MapRoute("Account", "Account/{action}/{accountId}",
new { controller = "Account", action = "Index", accountId = (string)null });
My editurl looks like this (includes account id, rows and page:
editurl:'/Account/SaveOrUpdateAccount?accountId='+$('fieldset#AccountDetails #Id').val()+'&rows='+$rows+'&page=1',
Actually, this is a known issue with Asp.net MVC, when you are using
a virtual directory.
However, using the Url.Action to generate the URL for the grid is sufficient.
It will append the application to the path, save this off into a string and
then apply the string to the url property of the grid.
<%
string path = Url.Action("ActionName", "Controller");
%>
<script>
var jqGridUrl = '<%=path%>'
url:jqGridUrl
The rendering engine gets upset when you try to evalue scripts in the jquery section, so just define it somewhere else and then use it.
Matthew
Most Users Ever Online: 715
Currently Online:
56 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66