DropdownHtmlAttribute migratin for Kendo combobox

5 posts, 1 answers
  1. Achilles
    Achilles avatar
    57 posts
    Member since:
    Jan 2013

    Posted 25 Jun 2013 Link to this post

    Hi,

    I am migrating my application from MVC Extensions to Kendo. I have a Combobox whose width (in the closed state) is 250px. But when it is open, the width of the dropdown is 400px. Please have a look at the attached screenshot.
    I achieve it with something like

    @(Html.Telerik().ComboBox().Name("CbPlants")
            ...
            ...
           .HtmlAttributes(new { style = "z-index: 20; width: 250px;" })
           .DropDownHtmlAttributes(new { style = "width: 400px;" })       
           )
           

      When I migrate it to Kendo, I couldn't find an equivalent to have a DropDownHtmlAttributes for customizing the width. Any idea how I can achieve this effect ?

    Thanks & Regards

    Achilles
  2. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2875 posts

    Posted 26 Jun 2013 Link to this post

    Hi Achilles,

    Width of ComboBox' drop-down list can be changed via jQuery width method. For example:
    @(Html.Kendo().ComboBox()
          .Name("customers")
          .DataTextField("ContactName")
          .DataValueField("CustomerID")
          .HtmlAttributes(new { style = "width: 400px" })
          .DataSource(source =>
          {
              source.Read(read =>
              {
                  read.Action("GetCustomers", "Home");
              });
          })
    )
    <script>
        $(function () {
            $("#customers").data("kendoComboBox").list.width(600);
        });
    </script>

    For more information please check this help topic:

    Regards,
    Alexander Valchev
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Answer
    Achilles
    Achilles avatar
    57 posts
    Member since:
    Jan 2013

    Posted 27 Jun 2013 Link to this post

    Hi Alexander,

    It worked. Thanks

    Regards

    Achilles
  5. Tony
    Tony avatar
    3 posts
    Member since:
    May 2012

    Posted 09 Oct 2013 Link to this post

    Is there any plan to support this with the Kendo MVC Extensions? (ie. no longer required to write the additional javascript to resize the list)

    Thanks,
    Tony
  6. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2875 posts

    Posted 10 Oct 2013 Link to this post

    Hello Tony,

    Currently widgets does not have a configuration option that allows the developer to set the width of the widget's Popup List, which is why there is no way to set this using MVC wrappers only.
    If you would like to see such feature added in one of our next releases, my recommendation is to submit a feature request at Kendo UI Feedback portal. In this way we will be able to track the community interest in it. If it turns out to be popular we will consider it.

    Regards,
    Alexander Valchev
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top
UI for ASP.NET MVC is VS 2017 Ready