This is a migrated thread and some comments may be shown as answers.

Serverfiltering (asp.net MVC versus Javascript)

2 Answers 58 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
NS
Top achievements
Rank 1
NS asked on 21 Mar 2018, 04:04 PM

Hi,

If I use Serverfiltering on the ASP.NET MVC dropdownlist control, my controller method is called with a string text parameter. (the text parameter contains the text that the user is typing on the dropdownlist)

If use serverfiltering on the HTML5/Javascript dropdownlist control, the text parameter is null.

If I look at it with developer tools in Chrome, there is a long querystring added that looks like this: Home/GetPurchasingOrganisations?filter%5Bfilters%5D%5B0%5D%5Bvalue%5D=test&filter%5Bfilters%5D%5B0%5D%5Bfield%5D=Value&filter%5Bfilters%5D%5B0%5D%5Boperator%5D=startswith&filter%5Bfilters%5D%5B0%5D%5BignoreCase%5D=true&filter%5Blogic%5D=and

 

How do I get the filter value out of this querystring in my controller?

Thanks,

Nicolas

2 Answers, 1 is accepted

Sort by
0
NS
Top achievements
Rank 1
answered on 22 Mar 2018, 10:15 AM
I solved it by reading out Request.QueryString["filter[filters][0][value]"]
0
Dimitar
Telerik team
answered on 23 Mar 2018, 12:08 PM
Hello Nicolas,

You have found the correct approach to pass the filter data to the server with the jQuery version of the DropDownList. The dataSource's tansport.read.data() method can be used to send the additional parameter to the server. Here is an alternative approach to get the filter:
<script>
$(document).ready(function () {
$("#news").kendoDropDownList({
filter: "contains",
dataTextField: "Name",
dataValueField: "Value",
dataSource: {                   
serverFiltering: true,
transport: {
read: {
url: "/ComboBox/GetNews",
data: function() {
var ddl = $("#news").getKendoDropDownList();
 
return {
text: ddl.filterInput.val()
}
                         
}
}
}
}
});
});
</script>

Regards,
Dimitar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
DropDownList
Asked by
NS
Top achievements
Rank 1
Answers by
NS
Top achievements
Rank 1
Dimitar
Telerik team
Share this question
or