Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
My MVC view has a grid and a detail partial view. When the user selects a row I need to have the detail partial view display. The detail partial view will be different based on the record type.

Here's the current code:
var grid = $("#grdAlertList").data("kendoGrid");
var row = grid.select();
var data = grid.dataItem(row);
$("#divAlertDetailList").load("@Url.Action("_AlertDetailDisplay", "AlertList",
new
{
inTenantId = "TenantId",
instanceId = "ActivityHistoryId"
})".replace("TenantId&", data.TenantId + '&').replace("ActivityHistoryId", data.ActivityHistoryId),
function (response, status, xhr) {
if (status == 'error')
alert(response);
//else
// _database.value = $("#divAlertDetailList".concat(row))[0].children.item().value;
});
}

What I would like to do is:
"@Url.Action("_AlertDetailDisplay" + Record-Type, "AlertList",

I am also open to allowing the Javascript code go to the same controller method and have it return the "proper" partial view.

Thanks for the assistance.

UPDATE: Found the solution. Used a placeholder name in the Url.Action and then did a replace on it.
$("#divAlertDetailList").load("@Url.Action("DynamicName", "AlertList",
new
{
inTenantId = "TenantId",
instanceId = "ActivityHistoryId"
})".replace("TenantId&", data.TenantId + '&').
replace("ActivityHistoryId", data.ActivityHistoryId).
replace("DynamicName", "_AlertDetailDisplay" + actionMethod),


where actionMethod = a JavaScript variable defined in the code.
Posted
Updated 1-Oct-14 8:13am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900