I have a MVC3 grid control ajax bound inside a detail page ("/Deal/Details/ASW%2093-2):
I setup the grid GridBindingSettingsBuilder.Select Method (String, String, Object) as follow:
.DataBinding(dataBinding => dataBinding.Ajax().Select("_PropertiesDetailsForLoanHierarchyAjax", "Deal", new { loanID = "<#= LOAN_ID #>" }))
The code generated in the client reads ("ASW%2093-2" was the ID of the Detail action):
ajax:{"selectUrl":"/Deal/_LoansForDealHierarchyAjax/ASW%2093-2?DealID=2"}I expected to see:
ajax:{"selectUrl":"/Deal/_LoansForDealHierarchyAjax/2"}<BR>This happens in all the Selects of this page (I have a details view grid inside this grid with the same problem). How do I get rid of the Details action route?
I have similar code in other pages (index pages) and the url created if fine.
Thanks
7 Answers, 1 is accepted
What is LOAN_ID? How is it initialized? The syntax you are trying to use would only work if this grid is defined in the DetailTemplate of another grid.
Regards,Atanas Korchev
the Telerik team
Loan_ID is the parameter needed to get loans to load a loans grid.
I have the following hierarchy Deal -> Loan -> Property. In a Deal Details Page (/Deal/Details/ASW%2094-C2) all the URLs get build with the page Route parameter "ASW%2094-C2" in it.
In the outer grid:
I have in View (.cshtml file):
.DataBinding(dataBinding => dataBinding.Ajax().Select("_LoansForDealHierarchyAjax", "Deal", new { dealID = @Model.DealID.ToString() }))
I get in client:
ajax:{"selectUrl":"/Deal/_LoansForDealHierarchyAjax/ASW%2094-C2?dealID=3"}
In the inner grid:
I have in View (.cshtml):
.DataBinding(dataBinding => dataBinding.Ajax().Select("_PropertiesDetailsForLoanHierarchyAjax", "Deal", new { loanID = "<#= LOAN_ID #>" }))
I get in client:
ajax:{%22selectUrl%22:%22/Deal/_PropertiesDetailsForLoanHierarchyAjax/ASW%252094-C2?loanID=%3c#=LOAN_ID#%3e%22}
Is it possible to not have the Details Page Route parameter in the URL?
ajax:{"selectUrl":"/Deal/_LoansForDealHierarchyAjax/3"}
instead of
ajax:{"selectUrl":"/Deal/_LoansForDealHierarchyAjax/ASW%2094-C2?dealID=3"}
By the way, the problem I had was that the controller's actions were not been called and, therefore, the grid was not loading. I thought that it had with the route since the URL had that extra information, but the problem was that the outer grid had a '>' at the end ("LoansHierarchyGrid>") of the name that caused it not to work at all. Even when I got it to work, I would like to know if I can build a cleaner URL.
Thank you
I still can't understand the exact scenario you are having. A sample project illustrating your setup would help me understand what the problem is.
Regards,Atanas Korchev
the Telerik team
I thought I was very explicit, but I will make it even simpler. Assumptions: reader knows ASP.Net MVC and Telerik Grids with Ajax binding. Here is the scenario:
If I have a grid with Ajax binding in an ASP.Net MVC page with the following:
Page URL where the grid resides (this is how I get the page with the grid):
“Mydomain.com/Deal/Details/ASW%2094-C2” and that translates to DomainName/[Controller]/[Action]/[id].
Code in the View (.cshtml file) to set up grid:
.DataBinding(dataBinding =>
dataBinding.Ajax().Select("_LoansForDealHierarchyAjax",
"Deal", new { dealID = @Model.DealID.ToString() }))
Code
that gets to the client (viewing source in browser):
ajax:{%22selectUrl%22:%22/Deal/_PropertiesDetailsForLoanHierarchyAjax/ASW%252094-C2?loanID=%3c#=LOAN_ID#%3e%22}
Please note that the URL for the action _PropertiesDetailsForLoanHierarchyAjax
contains and extra parameter or id (“ASW%252094-C2”). How do I get rid of it?????? And have a URL
as this “/Deal/_LoansForDealHierarchyAjax/3” where 3 is the ID
needed in the grid controller action that returns the Jason for Ajax binding
(_PropertiesDetailsForLoanHierarchyAjax).
The grid copies the current query string when displaying. You can try resetting that argument by passing empty string as dealID:
.DataBinding(dataBinding => dataBinding.Ajax().Select("_PropertiesDetailsForLoanHierarchyAjax", "Deal", new { dealID="", loanID = "<#= LOAN_ID #>" }))
Atanas Korchev
the Telerik team
ajax:{%22selectUrl%22:%22/Deal/_PropertiesDetailsForLoanHierarchyAjax?loanID=%3c#=LOAN_ID#%3e%22}
Is it possible to build it like this (no query string):
ajax:{%22selectUrl%22:%22/Deal/_PropertiesDetailsForLoanHierarchyAjax/%3c#=LOAN_ID#%3e%22}
Thank you
No it is not. The default route works only for integer arguments. <#= LOAN_ID #> is a string.
Kind regards,Atanas Korchev
the Telerik team