In MVC3 using VS 2010 I used this all the time no problem. You have an order. You want to be able to view the line items. So you click View in the Custom command of the data grid and it redirects you to a view with the line items for that order. I did this all the time with no issues
Problem: MVC4, VS 2012 and IE10. Same type of thing. Click the button, it calls the Ajax which calls the proper method in the controller and passes the parameter in but does not return the View.
I assume its a JQueary issue now. I have been pounding my head against the wall for a good day now and getting nowhere.
The View
@(Html.Kendo().Grid(Model).HtmlAttributes(gridAttributes)
.Name("grid")
.Columns(columns =>
{
columns.Command(command => { command.Edit().CancelText("Cancel"); command.Custom("Select").Click("showFields");}).Width(150);
columns.Bound(c => c.TableName).Width(200);
columns.Bound(c => c.FriendlyName).Width(200);
columns.Bound(c => c.SecurityLevel).Width(125);
columns.Bound(c => c.CanReportOn).Width(125).ClientTemplate("<
input
type
=
'checkbox'
#= CanReportOn ?
checked
=
'checked'
: '' #
value
=
'#=AdminTableId#'
class=\"check_row\"/>");
})
The Ajax call
BTW, the preventDefault makes no difference. Same result
function
showFields(e) {
// e.preventDefault();
var
dataItem =
this
.dataItem($(e.currentTarget).closest(
"tr"
));
var
tableName = dataItem.TableName;
$.ajax({
url:
'@Url.Action("ShowFields", "ProgramManager")'
,
type:
'POST'
,
data: { tableName: tableName }
});
}
The Controller method
public
ActionResult ShowFields(
string
tableName)
{
var list = appDb.AdminFields.Where(p => p.AdminTableName == tableName);
var model =
new
AdminFieldModel
{
Fields = list,
TableName = tableName
};
return
View(model);
}