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

Autocomplete width

9 Answers 1634 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
Alexius
Top achievements
Rank 1
Alexius asked on 03 Jan 2013, 11:25 PM
Hi all,

I have an input field what uses autocomplete, but the text I am displaying wraps in lines, so I want to make the dropdown list quite wider. tryied some solutions over the net but didn't find something, can someone help?

<form id="searchflightfrm">
search: <input type="text" id="fromair" name="fromair"  />
</form>
 
<script type="text/javascript">
         $(document).ready(function() {
                    $("#fromair").kendoAutoComplete({
                        minLength: 3,
                        dataTextField: "name",
                        filter: 'contains',
                        dataSource: {
                            type: "json",
                            serverFiltering: true,
                            serverPaging: false,
                            pageSize: 20,
                            transport: {
                                read: "json/data.jsp"
                            },
                        }
                    });
 </script>

9 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 04 Jan 2013, 08:24 AM
Hello Alexius,

To achieve that you could use the following code:
var autoComplete = $("#autoComplete").data("kendoAutoComplete");
autoComplete.list.width(400); //adjust width of the drop-down list

I hope this will help.

Kind regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Alexius
Top achievements
Rank 1
answered on 04 Jan 2013, 08:39 AM
Thanks! That really did the trick ;)

Can you pinpoint me where in the documentation I can find this so next time I know where to look?
0
Alexander Valchev
Telerik team
answered on 04 Jan 2013, 10:16 AM
Hello Alexius,

This is not a configuration setting which is why it is not documented. The approach uses jQuery width method and is demonstrated in the ComboBox "Customizing templates" demo. I have to admit that it is not very noticeably so we will consider adding a code snippet example in the overview topics.

Kind regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
SysDev
Top achievements
Rank 2
answered on 15 Mar 2014, 04:03 PM
I am having the same problem, but I am using the MVC wrappers. I have set the with of the autocomplete to 350px using the 
.HtmlAttributes but this sets the with of the autocomplete wrapper but not the dropdown list. for some reason this only goes to 280px...

0
Alexander Valchev
Telerik team
answered on 17 Mar 2014, 08:58 AM
Hi SysDev,

You should access the existing autoComplete widget after it is initialized and changed the width of its popup via JavaScript as described in my previous reply.
Please check the following help resources:

Regards,
Alexander Valchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Michael
Top achievements
Rank 1
answered on 20 Jan 2016, 05:30 PM

Alexander Valchev, might I trouble you for your input on how to adjust the width of my autocomplete in the code listed below?

 

@model EmployeeDirectory.Web.Mvc.Models.EmployeeEditViewModel
 
<div class="control-label form-group">
    @Html.LabelFor(model => model.Employee.Title, htmlAttributes: new { @class = "control-label col-xs-4" })
    <div class="col-xs-8 control">
        @if (Model.Permissions.CanEditEmployeeStatus)
        {
            @Html.TextBoxFor(model => model.Employee.Title.Name, htmlAttributes: new { @class = "col-xs-8 form-control", id = "titleAutoComplete" })
            @Html.ValidationMessageFor(model => model.Employee.Title, "", new { @class = "text-danger" })
        }
        else
        {
            @Html.TextBoxFor(model => model.Employee.Title.Name, htmlAttributes: new { @disabled = "disabled", @class = "col-xs-8 form-control" })
        }
    </div>
</div>
 
<script>
 
    $(document).ready(function() {
 
        // create ComboBox from input HTML element
        $("#titleAutoComplete").kendoAutoComplete({
            dataTextField: "Name",
            dataSource: {
                type: "json",
                transport: {
                    read: {
                        url: "/EmployeeDirectory/GetTitles"
                    }
                }
            },
            filter: "contains",
            suggest: true,
            index: 2,
            change: onTitleChange
        });
 
        function onTitleChange() {
            var newValue = $("#titleAutoComplete").val();
 
 
            $.ajax({
                url: "/EmployeeDirectory/UpdateTitle/" + @Model.Employee.Id,
                dataType: 'json',
                contentType: "application/json",
                data: "title=" + newValue,
                complete: function(response) {
                    $("#titleAutoComplete").data("kendoAutoComplete").dataSource.read();
                }
            });
 
            return true;
        }
 
    });
</script>

0
Alexander Valchev
Telerik team
answered on 22 Jan 2016, 08:35 AM
Hello Michael,

You can find example in the AutoComplete overview 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!
 
0
Roger
Top achievements
Rank 2
Veteran
answered on 16 May 2016, 11:53 PM

Hi Alexander:

I also am having problems widening the autocomplete dropdown.  3 years ago, you said " I have to admit that it is not very noticeably so we will consider adding a code snippet".  I have not been able to find one.  Could you let me know where I might find it or perhaps provide me with an example of how to do this using the mvc wrapper.

Thanks,

Roger

0
Alexander Valchev
Telerik team
answered on 18 May 2016, 12:00 PM
Hi Roger,

At first you should obtain a reference to the widget using this approach. Then use this approach to modify the width of the list.

Regards,
Alexander Valchev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
AutoComplete
Asked by
Alexius
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Alexius
Top achievements
Rank 1
SysDev
Top achievements
Rank 2
Michael
Top achievements
Rank 1
Roger
Top achievements
Rank 2
Veteran
Share this question
or