No items using ajax datasource with taghelper

2 posts, 0 answers
  1. Marcel
    Marcel avatar
    42 posts
    Member since:
    Apr 2011

    Posted 09 Mar 2018 Link to this post

    I have a problem configuring the MultiSelect using the taghelpers, while the htmlhelpers give me no problem at all.
    I get no data in the multiselect when using the taghelper, while the htmlhelper does.
    Any ideas ?

    Example:
    HtmlHelper:     

    @(Html.Kendo().MultiSelect()
                .Name("roleSelect")
                .DataTextField("roleName")
                .DataValueField("id")
                .DataSource(source =>
                {
                  source.Read(read =>
                  {
                    read.Action("GetAvailableRoles", "Users");
                  });
                })
    )

     

    Taghelper: 

    <kendo-multiselect name="roleSelect2" datavaluefield="id" datatextfield="roleName">
      <datasource type="DataSourceTagHelperType.Ajax">
        <transport>
          <read url="@Url.Action("GetAvailableRoles", "Users")" />
        </transport>
      </datasource>
    </kendo-multiselect>

     

     

     

  2. Neli
    Admin
    Neli avatar
    228 posts

    Posted 13 Mar 2018 Link to this post

    Hi Marcel,

    On the following link to our Demos you will find an example of using MultiSelect tag helpers.

    I have prepared a sample project containing MultiSelect with tag helpers. In Views - > Home - > Index.cshtml you will find the following configuration:
    @addTagHelper *, Kendo.Mvc
    <div class="demo-section k-content">   
        <kendo-multiselect name="orders"
                           placeholder="Select addresses..."
                           datatextfield="Name"
                           datavaluefield="Id"
                           value="new int[] { 3, 8 }">
            <datasource type="DataSourceTagHelperType.Ajax">
                <transport>
                    <read url="@Url.Action("GetProducts", "Home")" />
                </transport>
            </datasource>       
        </kendo-multiselect>  
    </div>

    And the respective action in HomeController:
    public ActionResult GetProducts([DataSourceRequest] DataSourceRequest request)
    {
    var products = Enumerable.Range(1, 50).Select(i => new ProductVM
    {
    Id = i,
    Name = "Name " + i
    });
     
    return Json(products.ToDataSourceResult(request));
    }

    May I ask you to modify the project in order to replicate the issue the way it is at your end? This will help us to inspect the problem locally and advise you further. 

    Regards,
    Neli
    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.
Back to Top