asp.net mvc - Searching/Filtering on All Columns in KendoUI Grid using DropdownlistFor -
i trying filter/search kendoui grid using custom dropdownlist. have been able result on singe column filtering if try add new dropdownlist filtering grid can't required result. problem logic operator , it's different values. correct way ? or other suggestions?
i add here images more description , hope me please. thanks
html dropdowns :
<html> <div class="form-group col-md-2" style="margin-bottom:0px;"> @html.label("media", htmlattributes: (new { @class = "col-sm-4 control-label" })) <div class="col-sm-8" style="float:none;"> @html.dropdownlistfor(model => model.mediatypeid, (viewdata["media"] selectlist), "select media", new { @class = "form-control btnregister chosen-select", onchange = "changes_dropdown(this.id)", data_placeholder = "select media", style = "border-bottom:none;border-radius:0px;" }) @* @html.validationmessagefor(model => model.mediatypeid, "", new { @class = "text-danger" })*@ </div> </div> <div class="form-group col-md-2" style="margin-bottom:0px;"> @html.label("outlet", htmlattributes: (new { @class = "col-sm-4 control-label" })) <div class="col-sm-8" style="float:none;"> @html.dropdownlistfor(model => model.channel, (viewdata["company"] selectlist), "select channel", new { @class = "form-control btnregister chosen-select", onchange = "changes_dropdown(this.id)", data_placeholder = "select channel", style = "border-bottom:none;border-radius:0px;" }) @html.validationmessagefor(model => model.channel, "", new { @class = "text-danger" }) </div> </div> <div class="form-group col-md-2" style="margin-bottom:0px;"> @html.label("start date", htmlattributes: (new { @class = "col-sm-6 control-label" })) <div class="col-sm-6" style="float:none;"> @html.dropdownlistfor(model => model.entrydate, (viewdata["entrydate"] selectlist), "select date", new { @class = "form-control btnregister chosen-select", onchange = "changes_dropdown(this.id)", data_placeholder = "select date", style = "border-bottom:none;border-radius:0px;", id = "startdate" }) @html.validationmessagefor(model => model.entrydate, "", new { @class = "text-danger" }) </div> </div> </html>
javascript function , filltering:
<script type="text/javascript"> function changes_dropdown(fieldid) { var fieldvalue = document.getelementbyid(fieldid).value; $("#grid").data("kendogrid").datasource.filter({ logic: "and", filters: [ { field: fieldid, operator: "contains", value: fieldvalue } ] }); } </script>
at first don't need pass id of current field changes_dropdown
function. instead can use onchange = "changes_dropdown()
, inside function use var fieldvalue = this.value
also when define single filter don't need specify logic between predicates (http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-filter):
$("#grid").data("kendogrid").datasource.filter({ filters: [ { field: fieldid, operator: "contains", value: fieldvalue } ] });
Comments
Post a Comment