我需要在下拉选择更改时更改 Telerik mvc 网格数据源。下面是我当前的视图,我想使用下拉选择更改网格。
<%@ Page Title="" Language="C#" MasterPageFile="~/ViewMasterPage.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<GateApplication.Models.Gate>>" %>
<%@ Import Namespace="Telerik.Web.Mvc.UI" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Index
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div align="left" style="width: 100%">
<table><tr>
<td>Search Form: </td>
<td><%= Html.Telerik().DropDownListFor(model => ViewData["drpSearch"])
.HtmlAttributes(new { @Style="width:250px" })
.BindTo(new SelectList((List<SelectListItem>)ViewData["drpSearch"], "Text", "Value"))%></td>
</tr></table>
</div>
<br />
<%= Html.Telerik().Grid(Model)
.Name("Grid")
.Columns(columns =>
{
columns.Bound(o => o.ID).Visible(false);
columns.Bound(o => o.Urgency);
columns.Bound(o => o.FullName);
columns.Bound(o => o.Email);
columns.Bound(o => o.GateSupportedBy);
columns.Bound(o => o.FullPhone1).Title("Phone Number");
columns.Bound(o => o.StNstNo).Title("St. and St. No.");
})
.DataBinding(dataBinding =>
{
dataBinding.Ajax().Select("AjaxGrid",
"Gate").Enabled(true);
})
.Scrollable(scrolling => scrolling.Enabled(true))
.Sortable(sorting => sorting.Enabled(true))
.Pageable(paging => paging.Enabled(true).PageSize(10))
.Filterable(filtering => filtering.Enabled(true))
.Groupable(grouping => grouping.Enabled(true))
.Footer(true)
%>
</asp:Content>