This question is locked. New answers and comments are not allowed.
Hi,
I have implemented server side grid.
now i would like to use the in form functionality. on create, edit the grid is directing to the action "Create"and "Edit".
How can i implement the if(ModelState.IsValid) and view the error messages in the grid windows.
the Grid located under Index action and the Create is on "Create" action.
some code:
Conroller:
[HttpPost]
public ActionResult Create(DataClassification dataClassification)
{
try
{
if (ModelState.IsValid)
{
_dataClassificationService.Insert(dataClassification);
return RedirectToAction("Index");
}
return View();
}
catch (Exception ex)
{
ViewBag.Message = ex.Message;
return View(dataClassification);
}
}
View:
@using Telerik.Web.Mvc.UI
@model IEnumerable<....DataClassification>
@{
var mode = GridEditMode.InLine;
var type = GridButtonType.Image;
}
<br/>
<div style="width: 60%;">
@(Html.Telerik().Grid(Model)
.Name("grid")
.ToolBar(commands => commands.Insert())
.DataKeys(keys => keys.Add(k => k.Id))
.DataBinding(dataBinding => dataBinding.Server()
.Delete("Delete", "DataClassification")
.Insert("Create", "DataClassification")
.Update("Edit", "DataClassification")
)
.Columns(columns =>
{
columns.Bound(a => a.Id).Width(10).Title("");
columns.Bound(a => a.Name).Width(250);
columns.Command(commands =>
{
commands.Delete().ButtonType(type);
commands.Edit().ButtonType(type);
}).Width(50);
}
)
.Editable(editing => editing.Mode(mode))
.Sortable()
.Footer(true)
)
</div>
in this case if the validation or exception is raising, i would like to get back to the grid on Create/Edit mode and let the user see the results.
Any advice would be appreciated
Thank you
Ori
I have implemented server side grid.
now i would like to use the in form functionality. on create, edit the grid is directing to the action "Create"and "Edit".
How can i implement the if(ModelState.IsValid) and view the error messages in the grid windows.
the Grid located under Index action and the Create is on "Create" action.
some code:
Conroller:
[HttpPost]
public ActionResult Create(DataClassification dataClassification)
{
try
{
if (ModelState.IsValid)
{
_dataClassificationService.Insert(dataClassification);
return RedirectToAction("Index");
}
return View();
}
catch (Exception ex)
{
ViewBag.Message = ex.Message;
return View(dataClassification);
}
}
View:
@using Telerik.Web.Mvc.UI
@model IEnumerable<....DataClassification>
@{
var mode = GridEditMode.InLine;
var type = GridButtonType.Image;
}
<br/>
<div style="width: 60%;">
@(Html.Telerik().Grid(Model)
.Name("grid")
.ToolBar(commands => commands.Insert())
.DataKeys(keys => keys.Add(k => k.Id))
.DataBinding(dataBinding => dataBinding.Server()
.Delete("Delete", "DataClassification")
.Insert("Create", "DataClassification")
.Update("Edit", "DataClassification")
)
.Columns(columns =>
{
columns.Bound(a => a.Id).Width(10).Title("");
columns.Bound(a => a.Name).Width(250);
columns.Command(commands =>
{
commands.Delete().ButtonType(type);
commands.Edit().ButtonType(type);
}).Width(50);
}
)
.Editable(editing => editing.Mode(mode))
.Sortable()
.Footer(true)
)
</div>
in this case if the validation or exception is raising, i would like to get back to the grid on Create/Edit mode and let the user see the results.
Any advice would be appreciated
Thank you
Ori