【发布时间】:2014-01-20 06:53:27
【问题描述】:
我想根据 ViewBag 值 letsay ViewBag.Category 在加载时过滤下面的 ProductData 下拉列表。我需要传递给 GetProductData() 的 viewbag 值。我怎么能做到这一点。谢谢
$("#ProductData").kendoDropDownList({
dataTextField: "OptionName",
dataValueField: "OptionID",
optionLabel: {
OptionName: "Please Select",
OptionID: ""
},
dataSource: {
transport: { read: { url: '@(Url.Content("~/ProductDetails/GetProductData"))'} }
}
});
<input type="ProductData" id="ProductData" name="ProductData" required validationMessage="Please select a product" style="width:110px; font-size:11px; margin-left:12px"/><span class="k-invalid-msg" data-for="ProductData"></span>
控制者:
//需要根据viewbag.category值进行过滤
public JsonResult GetProductData()
{
var productList = new TREntities();
string Role = ViewBag.Role;
return Json(productList .ConfigOptions.Select(c => new { OptionID = c.OptionID, OptionName = c.OptionName, OptionDetails = c.OptionDetails, OptionTypeID = c.ConfigTypeID })
.OrderBy(c => c.OptionName).Where(e => e.OptionID == 33), JsonRequestBehavior.AllowGet);
}
【问题讨论】:
-
您想将参数发送到 getProductData() 吗?像 getProductData(string catagory) 一样吗?
-
是的,类似的。字符串类别应该来自我认为使用 viewbag 的剃须刀页面。欢迎任何其他想法thx