I have a combobox separate from my grid and I want to use the comboBox selected value to filter the grid results. Do I need to do this in Java script? What is the best way to do this?
@(Html.Kendo().ComboBox()
.Name("comboBox")
.Size(ComponentSize.Small)
.DataTextField("Text")
.DataValueField("Value")
.Filter(DateTime.Today.Year.ToString())
.HtmlAttributes(new { style = "width:100%;" })
.BindTo(new List<SelectListItem>()
{
new SelectListItem() {
Text = "2018", Value = "2018"
},
new SelectListItem() {
Text = "2019", Value = "2019"
},
new SelectListItem() {
Text = "2020", Value = "2020"
},
new SelectListItem() {
Text = "2021", Value = "2021"
},
new SelectListItem() {
Text = "2022", Value = "2022"
},
new SelectListItem() {
Text = "2023", Value = "2023"
},
new SelectListItem() {
Text = "2024", Value = "2024"
}
})
)
@(Html.Kendo().Grid<Golf.DataAccess.Models.GoodGolfSchool>()
.Name("grid")
.Filterable()
.Columns(columns => {
columns.Bound(pkey => pkey.Id).Hidden(true);
columns.Bound(c => c.FirstName).Filterable(false);
columns.Bound(c => c.LastName);
columns.Bound(c => c.Email);
columns.Bound(c => c.VillageId).Width(100);
columns.Bound(c => c.ClassDateView).ClientTemplate("#=ClassDateView#")
.Filterable(f => f.Multi(true).CheckAll(false));
columns.Bound(c => c.Phone);
columns.Bound(c => c.EntryDate).Hidden();
columns.Command(cmd =>
{
cmd.Edit();
cmd.Destroy();
});
})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(20)
.ServerOperation(true)
.Read(read => read.Action("GolfSchoolRoster_Read", "GoodGolfSchools"))
.Update(update => update.Action("Student_Edit", "GoodGolfSchools"))
.Destroy(delete => delete.Action("Student_Distroy", "GoodGolfSchools"))
.Model(model =>
{
model.Id(p => p.Id);
model.Field(p => p.Id).Editable(false);
model.Field(p => p.EntryDate).Editable(false);
model.Field(p => p.ClassDateView).DefaultValue(
ViewData["ScheduleDates"] as Golf.DataAccess.Models.ClassDateViewModel);
})
.Filter(filters => {
filters.Add(model => model.ClassDate.Year).IsEqualTo([SELECTED VALUE FROM COMBOBOX ABOVE] );
})
)
.ToolBar(tools =>
{
tools.Excel().Text("Export To Excel");
})
.Excel(excel =>
{
excel.FileName("GoodGolfSchool.xlsx");
excel.AllPages(true);
})
.Pageable()
.Sortable()
.AutoBind(true)
.Editable(edit => edit.Mode(GridEditMode.InLine))
)