Reputation: 936
I want to filter ProductData dropdownlist below on load based on ViewBag value letsay ViewBag.Category. The viewbag value i need to pass to GetProductData(). How i can achieve this. Thank you
$("#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>
controller:
//Need to filter based on viewbag.category value
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);
}
Upvotes: 0
Views: 365
Reputation: 6633
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)
{
...
}
Upvotes: 1