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

Razor MVC Remote Datasource with filtering

1 Answer 141 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Shane
Top achievements
Rank 1
Shane asked on 26 Feb 2015, 06:49 PM
Hi,

I'm using the Razor HtmlHelper for the ComboBox populating the items on-demand and filtered much like your cascading combobox demo (http://demos.telerik.com/aspnet-mvc/combobox/cascadingcombobox). However my combobox needs to pass multiple filters to the server in a specific JSON object (filters must form part of an array) and data is returned in a JSON object. In summary I really need to have complete control of the request and response handling and would like to know the approach you'd recommend. Would a custom datasource be best with a parameterMap? I've not seen a real in-depth demo of how this is done with the Razor HtmlHelpers.

Lastly the server filtering I'm using adds in the filters currently like the demo mentioned above whereby you specify a javascript function name to supply the additional filters e.g. Data("filterProducts");. However I'm finding this rather limiting as I have a large number of comboboxs and each one must have it's own method, they all do the same thing pretty much however they rely on custom data attributes on the combobox box itself. Is there a way to have the combobox object/selector passed into the function?

Thanks,
Shane

1 Answer, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 02 Mar 2015, 02:38 PM
Hello Shane,

Both using a custom DataSource with a parameterMap and using the Data method are suitable approaches. You can use a single function for all ComboBox widgets and pass their unique IDs using a proxy function. For example: 
.Read(r=>r.Action("Read", "Controller").Data(@<text> additionalData("someID") </text>))
...
    function additionalData(id) {
        alert(id)
    }

Regards,
Alexander Popov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
ComboBox
Asked by
Shane
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Share this question
or