Is it possible to move to edit button to the toolbar?
I have a grid of users and would the user logged in should only be allowed to edit their own info.
The solution I’m looking for is either:
1: only show edit button for the row containing them self
2. An edit button in the toolbar that opens the edit form with their info.
My code so far:
@(Html.Kendo().TabStrip()
.Name("Afdelinger")
.Items(tabstrip =>
{
tabstrip.Add()
.Text("Odense")
.Selected(true)
.Content(
@<text>
@RenderEmployeeGrid("Odense")
</text>
);
tabstrip.Add()
.Text("Købbenhavn")
.Content(
@<text>
@RenderEmployeeGrid("København")
</text>
);
})
)
@helper RenderEmployeeGrid(string office)
{
@(
Html.Kendo().Grid<ADUser>()
.Name("ActiveDirectoryUsers" + office)
.Columns(columns =>
{
columns.Bound(p =>
p.ThumbnailPhoto64).Width(96).ClientTemplate("<img width='96'
height='96' src='data:image/png;base64,#=ThumbnailPhoto64#' />");
columns.Bound(m =>
m.DisplayName).Width(300);
columns.Bound(m =>
m.Mail).Width(125).ClientTemplate("<a href='mailto:#= Mail #'>#= Mail
#</a>");
columns.Bound(m =>
m.TelephoneNumber).Width(125).ClientTemplate("<a href='tel:#=
TelephoneNumber #'>#= TelephoneNumber #</a>");
columns.Bound(m =>
m.Mobile).Width(125).ClientTemplate("<a href='tel:#= Mobile #'>#= Mobile
#</a>");
columns.Command(commands
=>
{
commands.Custom("Vis").Click("showDetails");
commands.Edit();
}).Title("Commands").Width(200);
})
.ToolBar(toolbar =>
{
toolbar.Custom().Text("Click
me").Action("ADUser_Update", "ADUser");
})
.Sortable()
.Filterable()
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("ADUser_Update"))
.Pageable(pageable => pageable
.Refresh(true)
.PageSizes(true)
.ButtonCount(10))
.Events(events =>
events.DataBound("hideEditButton"))
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("MembersByOffice_JSON", "ADUser", new { Office = office }))
.Update(update => update.Action("ADUser_Update", "ADUser"))
.PageSize(10)
.Sort(sort => sort.Add(m =>
m.DisplayName))
.Model(model => {
model.Id(p =>
p.SAmAccountName);
model.Field(field =>
field.ThumbnailPhoto).Editable(false);
})
)
)
}
I have a grid of users and would the user logged in should only be allowed to edit their own info.
The solution I’m looking for is either:
1: only show edit button for the row containing them self
2. An edit button in the toolbar that opens the edit form with their info.
My code so far:
@(Html.Kendo().TabStrip()
.Name("Afdelinger")
.Items(tabstrip =>
{
tabstrip.Add()
.Text("Odense")
.Selected(true)
.Content(
@<text>
@RenderEmployeeGrid("Odense")
</text>
);
tabstrip.Add()
.Text("Købbenhavn")
.Content(
@<text>
@RenderEmployeeGrid("København")
</text>
);
})
)
@helper RenderEmployeeGrid(string office)
{
@(
Html.Kendo().Grid<ADUser>()
.Name("ActiveDirectoryUsers" + office)
.Columns(columns =>
{
columns.Bound(p =>
p.ThumbnailPhoto64).Width(96).ClientTemplate("<img width='96'
height='96' src='data:image/png;base64,#=ThumbnailPhoto64#' />");
columns.Bound(m =>
m.DisplayName).Width(300);
columns.Bound(m =>
m.Mail).Width(125).ClientTemplate("<a href='mailto:#= Mail #'>#= Mail
#</a>");
columns.Bound(m =>
m.TelephoneNumber).Width(125).ClientTemplate("<a href='tel:#=
TelephoneNumber #'>#= TelephoneNumber #</a>");
columns.Bound(m =>
m.Mobile).Width(125).ClientTemplate("<a href='tel:#= Mobile #'>#= Mobile
#</a>");
columns.Command(commands
=>
{
commands.Custom("Vis").Click("showDetails");
commands.Edit();
}).Title("Commands").Width(200);
})
.ToolBar(toolbar =>
{
toolbar.Custom().Text("Click
me").Action("ADUser_Update", "ADUser");
})
.Sortable()
.Filterable()
.Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("ADUser_Update"))
.Pageable(pageable => pageable
.Refresh(true)
.PageSizes(true)
.ButtonCount(10))
.Events(events =>
events.DataBound("hideEditButton"))
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("MembersByOffice_JSON", "ADUser", new { Office = office }))
.Update(update => update.Action("ADUser_Update", "ADUser"))
.PageSize(10)
.Sort(sort => sort.Add(m =>
m.DisplayName))
.Model(model => {
model.Id(p =>
p.SAmAccountName);
model.Field(field =>
field.ThumbnailPhoto).Editable(false);
})
)
)
}