This question is locked. New answers and comments are not allowed.
When defining a Command column with Edit and/or Delete buttons, an unrelated Ajax call fails. Column definition like:The Select() command works fine and the order of commands doesn't appear to make a difference. If Edit() or Delete() are used, Ajax calls (outside of the grid) fail. Note the grid itself is using Ajax() binding:.Columns(columns =>
{
columns.Bound(m => m.Quantity).Width(100);
...
columns.Command(commands =>
{
commands.Edit().ButtonType(GridButtonType.Text);
commands.Delete().ButtonType(GridButtonType.Text);
}).Width(180).Title("Commands");
})
That is, the Ajax call is received in the controller, executes and returns but triggers an error rather than success on the page. Ajax code is like:<%= Html.Telerik().Grid<
RecipeIngredientModel
>()
.Name("IngredientsList")
//.TableHtmlAttributes(new { style = "table-layout:fixed" })
.DataKeys(keys => keys.Add(m => m.Id))
.ToolBar(commands => commands.Insert().ButtonType(GridButtonType.Text).HtmlAttributes(new { value = "Add new ingredient", style = "margin-left:0" }))
.DataBinding(dataBinding => dataBinding.Ajax()
.Select("SelectAjaxIngredients", "Cookbook", new { recipeId = Model.Id })
.Insert("InsertAjaxIngredient", "Cookbook", new { recipeId = Model.Id })
.Update("UpdateAjaxIngredient", "Cookbook", new { recipeId = Model.Id })
.Delete("DeleteAjaxIngredient", "Cookbook", new { recipeId = Model.Id }))
.Columns(columns =>
{
columns.Bound(m => m.Quantity).Width(100);
columns.Bound(m => m.Unit.Unit).Width(130);
columns.Bound(m => m.Ingredient).Width(230).ClientTemplate("<#= Ingredient.IngredientName #>").Title("IngredientId");
columns.Bound(m => m.Preparation).Width(500);
columns.Command(commands =>
{
commands.Edit().ButtonType(GridButtonType.Text);
commands.Delete().ButtonType(GridButtonType.Text);
}).Width(180).Title("Commands");
})
.Editable(editing => editing.Mode(GridEditMode.InLine))
.Footer(true)
%>
with controller action:$.ajax({
type: "POST",
url: "/Home/TestJson",
dataType: "json",
data: ({ 'recipeId': 1, 'ingredientInfoId': 10 }),
success: function (data) {
alert("Success from Json ");
},
error: function (req, status, error) {
alert("failure from Json");
}
});
Any ideas for a workaround or fix?GET and POST have the same affect.[HttpPost]
public JsonResult TestJson(int recipeId, int ingredientInfoId)
{
return Json(new { string.Empty });
}