我在我的项目中使用 Telerik 控件。如何使用示例项目 mvc3+razor(cshtml) 将 Telerik 下拉菜单嵌入到 Telerik 网格视图中,并且控制器代码是 c#?
问问题
2098 次
1 回答
0
从控制器仅使用 TempData 或 ViewBag 将数据传递给视图。
List<AdjustmentReasonCodes> salesAuditReasons = new List<AdjustmentReasonCodes>();
salesAuditReasons = salesDal.SalesAuditResonCodes();
TempData["SalesAuditReason"] = salesAuditReasons;
TempData["CStatus"] = salesDal.ReadCustomerListWithRecoveryStatus(objLoginHelper.LogInForUnitCode, Convert.ToByte(ctype), Helper.DateTo(Helper.YearMonthPrevious(2)));
现在只需使用视图页面的列表来保存TempData
@{
List<AdjustmentReasonCodes> salesAuditReasons = new List<AdjustmentReasonCodes>();
salesAuditReasons = (List<AdjustmentReasonCodes>)TempData["SalesAuditReason"];
}
您可以使用模板非常轻松地添加组合框。
<div class="DataGridXScroll">
@{
List<GetCustomerListWithRecoveryStatus> listCustomerStatus = new List<GetCustomerListWithRecoveryStatus>();
listCustomerStatus = (List<GetCustomerListWithRecoveryStatus>)TempData["CStatus"];
if (listCustomerStatus != null)
{
@(Html.Telerik().Grid(listCustomerStatus)
.Name("grvSalesAdjustment")
.DataKeys(keys => keys.Add(k => k.CustCode))
.Columns(column =>
{
column.Bound(a => a.CustCode).Width(100).HtmlAttributes(new { @class = "GridColumnLeftAlign" }).Title("Customer ID");
column.Template(@<input type="text" class="GridTextBoxRightAlign" style="width:62px;" id="@("salesAudit" + @item.CustCode.Replace(" ", "").Replace("-", "").Trim())" value="@(@item.AuditAdjustmentWithoutDPInCurrentMonth.ToString("0"))" />).Title("Audit Adjustment").Width(80);
column.Template(@<select id="@("ddlSalesAuditReason" + @item.CustCode.Replace(" ", "").Replace("-", "").Trim())" class="DropDown">
<option value="0">--Select--</option>
@foreach (AdjustmentReasonCodes adrc in salesAuditReasons)
{
if (item.RefReasonForAuditAdjustment == adrc.ReasonCode)
{
<option value="@(adrc.ReasonCode)" selected="selected">@adrc.ReasonDescription</option>
}
else
{
<option value="@(adrc.ReasonCode)">@adrc.ReasonDescription</option>
}
}
</select>).Title("Audit Reason").Width(135);
}).Selectable()
.Pageable(page => page.PageSize(100))
.Scrollable(scroll => scroll.Height(300))
)
}
}
</div>
于 2012-07-07T08:05:22.313 回答