This question is locked. New answers and comments are not allowed.
How do I add BOTH a toolbar template AND the Insert Command Button to the Grid?
Calling the .Toolbar() two times like below doesn't work - probably one overwrites the other...
Calling the .Toolbar() two times like below doesn't work - probably one overwrites the other...
Html.Telerik().Grid<Address>(Model)
.Name(
"AddressGrid"
)
.DataKeys(keys => keys.Add(c => c.Id))
.ToolBar(toolBar => toolBar.Template(() =>
{
Response.Write(
"Name: "
);
Response.Write(
" <input type=\"text\" id=\"txtAddressSearch\" value=\"\" onkeyup=\"addressSearch()\" class=\"t-widget t-autocomplete t-input\" style=\"width: 200px; margin-top:1px;\" />"
);
})
)
.ToolBar(commands => commands.Insert().ButtonType(GridButtonType.Text))
.Columns(columns =>
{
columns.Bound(a => a.Name).Width(120);
columns.Bound(a => a.Street).Width(150);
columns.Bound(a => a.ZipCode).Width(60);
columns.Bound(a => a.City).Width(100);
columns.Bound(a => a.State).Width(90);
columns.Bound(a => a.Country).Width(90);
columns.Command(commands =>
{
commands.Edit().ButtonType(GridButtonType.Text);
commands.Delete().ButtonType(GridButtonType.Text);
}).Width(175).Title(
""
);
})
.DataBinding(dataBinding =>
{
dataBinding.Ajax().Select(
"_AddressGrid"
,
"Address"
).Enabled(
true
)
.Insert(
"_GridInsert"
,
"Address"
)
.Update(
"_GridSave"
,
"Address"
)
.Delete(
"_GridDelete"
,
"Address"
);
})
.Selectable()
.Editable(editing => editing.Mode(GridEditMode.InLine))
.ClientEvents(events => events.OnRowSelect(
"addressOnRowSelected"
))
.Scrollable(scrolling => scrolling.Enabled(
true
))
.Sortable(sorting => sorting.Enabled(
true
))
.Pageable(paging => paging.Enabled(
true
))
.Filterable(filtering => filtering.Enabled(
true
))
.Groupable(grouping => grouping.Enabled(
true
))
.Reorderable(reorder => reorder.Columns(
true
))
.Footer(
true
)
.Render();