<div class="demo-section k-content">
    <h4>Find a product</h4>

    @(Html.Kendo().Button()
        .Name("textButton")
        .Content("Set Datasource")
        .HtmlAttributes( new {type = "button"} )
        .Events(ev => ev.Click("onClick"))
    )

    @(Html.Kendo().MultiSelect()
         .Name("msInvoicesAPV")
         .Placeholder("Select invoices...")
         .HtmlAttributes(new { required = "required", style = "width: 100%", validationmessage = "Select Invoice Numbers." })
         .DataTextField("ProductName")
         .DataValueField("ProductID")
         .AutoBind(true)


         .DataSource(source =>
                 {
             source.Read(read =>
             {
                 read.Action("ServerFiltering_GetProducts", "Home");
             })
             .ServerFiltering(true);
         })

    )

     @(Html.Kendo().MultiSelect()
         .Name("msInvoicesAPV1")
         .Placeholder("Select invoices...")
         .HtmlAttributes(new { required = "required", style = "width: 100%", validationmessage = "Select Invoice Numbers." })
         .DataTextField("ProductName")
         .DataValueField("ProductID")
         .AutoBind(true)
    )



    <script>
        function onClick() {
            //alert();
            var dataSource = new kendo.data.DataSource({
                batch: true,
                transport: {
                    read:  {
                        url: "/Home/ServerFiltering_GetProducts",
                        dataType: "json"
                    },
                    
                    parameterMap: function(options, operation) {
                        if (operation !== "read" && options.models) {
                            return {models: kendo.stringify(options.models)};
                        }
                    }
                },
                schema: {
                    model: {
                        id: "ProductID",
                        fields: {
                            ProductID: { type: "number" },
                            ProductName: { type: "string" }
                        }
                    }
                }
            });

            var multi = $("#msInvoicesAPV1").data("kendoMultiSelect");
            multi.setDataSource(dataSource);
        }
    </script>


</div>