Here's my grid on my Index.cshtml page:
@model IEnumerable<PosPayAndBankRec.Models.AccountListItem>
@{
ViewBag.Title = "Account List";
}
<div id="grid"></div>
@(Html.Kendo().Grid(Model)
.Name("Grid")
.ToolBar(p => p.Create())
.Columns(columns =>
{
columns.Bound(p => p.SourceName).Groupable(false).Title("Source");
columns.Bound(p => p.BankName).Title("Bank");
columns.Bound(p => p.AccountName).Title("Account");
columns.Bound(p => p.AccountNumber).Title("Acct #");
columns.Bound(p => p.AccountFolderName).Title("Folder");
columns.Bound(p => p.RamQuestBankNumber).Title("Bank #");
columns.Bound(p => p.AccountID).Hidden(true);
columns.Command(p => p.Edit());
columns.Command(p => p.Destroy());
})
.Pageable()
.Editable(c => c.Mode(GridEditMode.PopUp).Enabled(true).DisplayDeleteConfirmation(true).Window(window => window.Title("Account")).TemplateName("AccountPopup"))
.Sortable()
.Scrollable()
.Filterable()
.DataSource(dataSource => dataSource
.Ajax()
.Sort(sort => sort.Add(p => p.BankName))
.ServerOperation(false)
.Model(model => model.Id(p => p.AccountID))
//.Model(d => d.Id("AccountID"))
.Update(update => update.Action("Edit", "Account"))
.Create(create => create.Action("Create", "Account"))
.Destroy(destroy => destroy.Action("Delete", "Account"))
)
)
Here's my AccountPopup.cshtml:
@using System.Collections
@model PosPayAndBankRec.Models.AccountListItem
@{
ViewBag.Title = "Account";
SelectList sources = new SelectList("");
SelectList banks = new SelectList("");
if (Model.Sources != null)
{
sources = new SelectList(Model.Sources, "SourceID", "SourceName");
banks = new SelectList(Model.Banks, "BankID", "BankName");
}
}
<table id="table">
<tr>
<td>
Source
</td>
<td>
@Html.DropDownListFor(m => m.SourceID, sources)
</td>
</tr>
<tr>
<td>
Bank
</td>
<td>
@Html.DropDownListFor(m => m.BankID, banks)
</td>
</tr>
</table>