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.