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

No items using ajax datasource with taghelper

1 Answer 372 Views
MultiSelect
This is a migrated thread and some comments may be shown as answers.
Marcel
Top achievements
Rank 1
Marcel asked on 09 Mar 2018, 12:31 PM

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>

 

 

 

1 Answer, 1 is accepted

Sort by
0
Neli
Telerik team
answered on 13 Mar 2018, 03:28 PM
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.
Tags
MultiSelect
Asked by
Marcel
Top achievements
Rank 1
Answers by
Neli
Telerik team
Share this question
or