or
Kendo.Mvc.UI.Menu menu = Kendo.Mvc.UI.HtmlHelperExtension.Kendo(helper).Menu();
menu.Name =
"MainMenu"
;
IList<MenuItem> items =
new
List<MenuItem>();
items.Add(
new
MenuItem { Text =
"Dashboard"
, Action =
"Index"
, Controller =
"Dashboard"
});
items.Add(
new
MenuItem { Text =
"Certificates"
, Action =
"Index"
, Controller =
"Certificates"
});
UrlHelper Url =
new
UrlHelper(helper.ViewContext.RequestContext);
string
controller = helper.ViewContext.RouteData.GetRequiredString(
"controller"
);
foreach
(MenuItem item
in
items)
{
menu.Items.Add(
new
Kendo.Mvc.UI.MenuItem { Url = Url.Action(item.Action,item.Controller),Text = item.Text, Selected = (item.Controller == controller)});
}
return
new
MvcHtmlString(menu.ToHtmlString());
@(Html.Kendo().Grid<
UserModel
>()
.Name("Users")
.ToolBar(commands => { commands.Create().Text("Create new User"); })
.Columns(columns =>
{
columns.Bound(o => o.uidIdentity).Hidden();
columns.Bound(o => o.UserName).Title("Users Name").Sortable(true).Filterable(true).Width(200)
.HeaderHtmlAttributes(new { style = "text-align:center;align=center" }).HtmlAttributes(new { style = "text-align:center;align=center" });
columns.Bound(o => o.Email).Title("Email Address ").Sortable(true).Filterable(true).Width(175)
.HeaderHtmlAttributes(new { style = "text-align:center;align=center" }).HtmlAttributes(new { style = "text-align:center;align=center" });
})
.Events(events => events.DataBound("UserGrid_DataBound").Edit("UserGrid_edit"))
.ClientDetailTemplateId("roleTemplate")
.Sortable()
.Editable(editing =>
editing.Mode(GridEditMode.PopUp).Window(w => w.HtmlAttributes(new { })))
.DataSource(dataSource => dataSource
.Ajax()
.Events(e => e.Error("error_handler"))
.Read("_GetTpaUser", "User")
.Create("_InsertUser", "User")
.Update("_EditUser", "User")
.Destroy("_DeleteUser", "User")
.Model(model => model.Id(o => o.UserName))
)
.Filterable()
.Scrollable(scroll => scroll.Enabled(true).Height(500))
.Resizable(resize => resize.Columns(true))
.Pageable(pager => pager.PageSizes(true))
)
public JsonResult UserNameExists(string UserName)
{
AccountRepository _repository = new AccountRepository();
if (!(_repository.CheckUserNameExists(UserName)))
return Json(true, JsonRequestBehavior.AllowGet);
else
return Json(string.Format("User name: {0} is already in use.", UserName), JsonRequestBehavior.AllowGet);
}
public class UserModel
{
#region Constructor
public UserModel()
{
}
#endregion
private AccountRepository _reposAcct = new AccountRepository();
private spGetUserProfileResult _UserProfile = new spGetUserProfileResult();
public Guid UserGuiD { get; set; }
public int UserID { get; set; }
[Required(ErrorMessage = "First Name Required")]
[DisplayName("First Name:")]
public string FirstName
{
get
{
return _UserProfile.FirstName;
}
set
{
_UserProfile.FirstName = value;
}
}
[Required(ErrorMessage = "Last Name Required")]
[DisplayName("Last Name:")]
public string LastName
{
get
{
return _UserProfile.LastName;
}
set
{
_UserProfile.LastName = value;
}
}
[Required(ErrorMessage = "User Name Required")]
[Remote("UserNameExists", "AddUserLogin", "Administration")]
[DisplayName("User Name:")]
public string UserName { get; set; }
[Required(ErrorMessage = "Email Address Required")]
[ValidateEmail(ErrorMessage = "A valid email address is required")]
[DataType(DataType.EmailAddress)]
[DisplayName("Email Address:")]
public string Email { get; set; }
}
01.
function
kendoGridErrorHandler(args) {
02.
if
(args.errors == undefined) {
03.
if
(args.xhr.status == 403) {
04.
updatePrimaryMessage(
"You are not authorised to carry out that operation."
,
true
);
05.
}
else
if
(args.xhr.status == 401) {
06.
updatePrimaryMessage(
"You need to be logged in to carry out that operation."
,
true
);
07.
}
else
if
(args.xhr.status == 500) {
08.
updatePrimaryMessage(
"The operation did not complete because of an error."
,
true
);
09.
}
else
{
10.
updatePrimaryMessage(
"There was problem. Please refresh the screen."
,
true
);
11.
}
12.
$(
'#PrimaryKGrid'
).data().kendoGrid.one(
'dataBinding'
,
function
(e) {
13.
e.preventDefault();
14.
});
15.
}
else
{
16.
//error means Ajax error response. customerror means Kendo error response
17.
var
grid = $(
'#PrimaryKGrid'
).data(
"kendoGrid"
);
18.
grid.one(
"dataBinding"
,
function
(e) {
19.
e.preventDefault();
// cancel grid rebind if error occurs
20.
//We have formatted errors to display
21.
for
(
var
error
in
args.errors) {
22.
showMessage(grid.editable.element, error, args.errors[error].errors);
23.
}
24.
});
25.
}
26.
}
@(Html.Kendo().Grid<
ToolListItemView
>().Name("texListGrid")
.Columns(columns => {
columns.Bound(m => m.ToolId);
columns.Bound(m => m.Description).HtmlAttributes(new { style = "font-size: 1.3em;" });
columns.Bound(m => m.LastModified);
columns.Bound(m => m.ConditionName);
columns.Bound(m => m.LocationName);
})
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("ToolsRead", "List").Data("listParams"))
)
)
@(Html.Kendo().ComboBox()
.Name("ID_Poblacion")
.DataValueField("Item1")
.DataTextField("Item2")
.DataSource(dataSource => dataSource // Configure the grid data source
.Read(read => read.Action("Items", "Poblacion", new { Area = "DataAPI" }))
)
.Value(Model.ID_Poblacion.ToString())
)
grid.bind("edit", function (e) {
window.location = '@Url.Action("AddEditCoalition","Form",new{coalitionId=Model.CoalitionId})' + '&formId=' + e.model.Id;
});