Kendo Dropdownlist with ServerFiltering and Contains-Filter

1 Answer 1022 Views
DropDownList
Jan-Frederik
Top achievements
Rank 1
Iron
Iron
Jan-Frederik asked on 14 Sep 2022, 06:44 AM

Hi, I have a Kendo Dropdownlist with ajax datasource, ServerFiltering and a contains filter.

Unfortunately, the contains filter does not work. I tried to pass the "text" parameter in the data-function of the dropdownlist, but without success.

<select id="multiselect" multiple="multiple"></select> $("#multiselect").kendoDropDownList({ name: "dataSelect", filter: "contains", dataSource: { type: "aspnetmvc-ajax", serverFiltering: true, transport: { read: { type: "POST", url: "@Url.Page("Data", "ReadData")", data: function() {

//var text = $('#dataSelect').data("kendoDropDownList").filterInput; not working

//var data = { text: text };
                    //return $.extend(kendo.antiForgeryTokens(), data);

return kendo.antiForgeryTokens(); } } } });

public ActionResult OnPostReadData([DataSourceRequest] DataSourceRequest request, string text)
{

}


1 Answer, 1 is accepted

Sort by
0
Aleksandar
Telerik team
answered on 19 Sep 2022, 05:05 AM

Hi Jan-Frederik,

From the details shared it is not exactly clear what the actual issue is. I see that the endpoint is configured to use the DataSource and returns a DataSourceResult object. In this scenario a schema and a data field should also be set, to indicate the field from the response containing the array of items the component will display.

<input id="ddl" />
<script>
$("#ddl").kendoDropDownList({
    name: "dataSelect",
    dataTextField:"ShipName",
    dataValueField:"OrderID",
    filter: "contains", 
    dataSource: {
        type: "aspnetmvc-ajax",
        serverFiltering: true,
        schema:{
            data:"Data"
        },
        transport: {
            read: {
                type: "POST",
                url: "@Url.Page("Index", "GetData")",
                data: function() {
                    return kendo.antiForgeryTokens()
                }
            }
        }
    }
});
</script>
With the type of he dataSource set to "aspnetmvc-ajax" the dataSource will send details on the applied filter:

If you need to access any of the filter fields - Member, Operator and/or Value you can do so by accessing the Filters property of the DataSourceRequest object:

I am attaching a sample application for you to review.

Let me know if you have any additional questions.

Regards,
Aleksandar
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
DropDownList
Asked by
Jan-Frederik
Top achievements
Rank 1
Iron
Iron
Answers by
Aleksandar
Telerik team
Share this question
or