【问题标题】:Bind KendoUi dropdownlist绑定 KendoUi 下拉列表
【发布时间】: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

标签: asp.net-mvc-4 kendo-ui


【解决方案1】:
 transport:{ read: {
            dataType: "json",
            url:  "ProductDetails/GetProductData",
            data: getTestData
        }}

      function getTestData() 
      {
              return {testID: parameterToSent}  // you can take parameterToSent from where you want
      };

public JsonResult GetProductData(string testID)
    {
       ...

    }

【讨论】:

  • 这是您从视图向控制器发送参数的方式。我不知道你的控制器功能是真是假
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-02-10
  • 1970-01-01
  • 1970-01-01
  • 2013-04-23
  • 2021-02-25
相关资源
最近更新 更多