<table id="table">
<tr>
<td>
Bank
</td>
<td>
@(Html.Kendo().DropDownList()
.Name("banks")
.OptionLabel("-- Select Item --")
.DataTextField("BankName")
.DataValueField("BankId")
.DataSource(source => {
source.Read(read =>
{
read.Action("GetCascadeBanks", "Home");
});
})
)
</td>
</tr>
<tr>
<td>
Account
</td>
<td>
<script>
function filterAccounts() {
return {
banks: $("#banks").val()
};
}
</script>
@(Html.Kendo().DropDownList()
.Name("accounts")
.OptionLabel("-- Select Item --")
.DataTextField("AccountName")
.DataValueField("AccountID")
.DataSource(source => {
source.Read(read =>
{
read.Action("GetCascadeAccounts", "Home")
.Data("filterAccounts");
})
.ServerFiltering(true);
})
.Enable(false)
.AutoBind(false)
.CascadeFrom("banks")
)
</td>
</tr>
</table>
public JsonResult GetCascadeBanks()
{
var ortbanks = from bank in db.ORTBanks
orderby bank.BankName
select new TreasuryCreateItem()
{
BankID = bank.BankID,
BankName = bank.BankName,
};
return Json(ortbanks, JsonRequestBehavior.AllowGet);
}
public JsonResult GetCascadeAccounts(int banks)
{
var ortaccounts = from account in db.ORTAccounts
where account.AccountName != string.Empty
orderby account.AccountName
select new TreasuryCreateItem()
{
AccountID = account.AccountID,
AccountName = account.AccountName,
};
var accountsInBank = from p in ortaccounts where p.BankID == banks select p;
return Json(accountsInBank, JsonRequestBehavior.AllowGet);
}
$(document).ready(function () {
$("#grid").kendoGrid({
dataSource: {
type: "json",
transport: {
read: {
url: '<%= Url.Action("GetDepartmentOffers", "Projects") %>',
dataType: "json",
type: "POST",
data: {
departmentId: 1,
filter: 'all'
}
}
},
schema: {
model: {
fields: {
status: { type: "string" },
ResponsibleUserName: { type: "string" },
OfferNumber: { type: "string" },
DueDate: { type: "date" },
ContactPhone: { type: "string" },
CompanyName: { type: "string" },
ContactPerson: { type: "string" },
ContactEmail: { type: "string" },
Description: { type: "string" },
SalesPrice: { type: "string" },
Coverage: { type: "string" }
}
},
total: function () { return 4677; }
},
pageSize: 50,
serverPaging: false,
serverFiltering: false,
serverSorting: false
},
autoBind: true,
groupable: true,
sortable: true,
reorderable: true,
resizable: true,
pageable: {
messages: { // To be translated
display: "kendo.data.DataSource - {1} of {2} items",
empty: "No items to display",
page: "Page",
of: "of kendo.data.DataSource",
itemsPerPage: "visninger på hver side.",
first: "Gå til første side.",
previous: "GÃ¥ til forrige side.",
next: "Go to the next page",
last: "Go to the last page",
refresh: "Refresh"
},
refresh: true,
pageSizes: true,
pageSizes: [10, 20, 50, 100]
},
columns:
[
{
field: "status",
width: 90,
title: '<%= Global.State %>'
}, {
field: "",
width: 90,
title: '<%= Global.Actions %>'
}, {
field: "ResponsibleUserName",
width: 100,
title: '<%= OffersOverview.ColumnHeaderUser %>'
}, {
field: "OfferNumber",
width: 100,
title: '<%= OffersOverview.ColumnHeaderOfferNumber %>'
}, {
field: "DueDate",
width: 100,
title: '<%= Global.DueDate %>',
format: "{0:" + settings.dateFormat + "}"
//format: //"{0:MM/dd/yyyy}"
}, {
field: "ContactPhone",
width: 100,
title: '<%= Global.ContactPhone %>'
}, {
field: "CompanyName",
width: 100,
title: '<%= Global.Company %>'
}, {
field: "ContactPerson",
width: 100,
title: '<%= Global.ContactPerson %>'
}, {
field: "ContactEmail",
width: 100,
title: '<%= Global.ContactMail %>'
}, {
field: "Description",
width: 100,
title: '<%= Global.Description %>'
}, {
field: "SalesPrice",
width: 100,
title: '<%= Global.SalesPrice %>'
}, {
field: "Coverage",
width: 100,
title: '<%= Global.Coverage %>'
}
]
});
});