Client-Side syntax for Datasource with a parameter on Dynamic creation of DropDownList

2 posts, 0 answers
  1. Greg
    Greg avatar
    24 posts
    Member since:
    Dec 2014

    Posted 17 Feb Link to this post

    I'm having to dynamically create instances of the kenod dropdownlist and I have it working fine except I need to know what the equivalent syntax for defining the datasource.


    Here is the razor server-side syntax:


                            .HtmlAttributes(new { style = "width:100%", @class = "itemTypeClass", required = "required" })
                            .DataSource(source => { source.Read(read => { read.Action("GetItemTypes", "RequestPONumber").Data("GetSelectedLocation"); }); })

    Action is GetItemTypes

    Controller is RequestPONumber

    Here is my client-side:

    var newItemTypeDdl = $("#itemTypeddl" + poLinesCount).kendoDropDownList(
                    dataTextField: 'Name',
                    dataValueField: 'Code',
                    dataSource: ??????,
                    optionLabel: "..........",


  2. Georgi Krustev
    Georgi Krustev avatar
    3688 posts

    Posted 19 Feb Link to this post

    Hello Greg,

    I answered to the support thread opened on the same subject. I would like to ask you continue the discussion in only one thread to avoid duplication. Thank you in advance.

    As to the question, you can create a DataSource instance using the datasource of the initial dropdownlist. You can either get the URL and fetch the data again or just use it directly. I suppose that you wouldn't need to re-fetch it. In this case, the code will like something like this:
    var dataSource = $("#lineItemTypeCode").data("kendoDropDownList").dataSource;
    var newDS = new{
      data: new

    If you still need to fetch the data, then you can just serialize the URL and use it in the dataSource creation:
    var url = "@Url.Action("GetItemTypes", "RequestPONumber")";
    //use the url in the datasource creation

    Georgi Krustev
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET AJAX banner
Back to Top