Adjusting Telerik RadComboBox dropdown width dynamically based on content

16 views Asked by At

I'm using Telerik's RadComboBox in my ASP.NET application, and I'm trying to make the dropdown width adjust dynamically based on the content. Currently, I have the following RadComboBox setup in my code:

<telerik:RadComboBox ID="wcProductCode" runat="server" CssClass="codingwidthControl" Height="150px" MaxLength="50" DataTextField="DbComboText" OnClientItemsRequested="AfterClientItemRequested" DataValueField="DbComboValue" ItemsPerRequest="10" DropDownAutoWidth="Enabled" ShowMoreResultsBox="true" EnableVirtualScrolling="true" OnClientKeyPressing="OnGlobalClientKeyPressing" OnClientBlur="CheckProductText" OnClientItemsRequesting="wcProductCode_BeforeRequestItems" OnClientSelectedIndexChanged="OnClientSelectedIndexChangedItem">
    <WebServiceSettings Method="DBMethod_ProductCode" Path="~/Services/PurchaseRequisitionForm.asmx" />
</telerik:RadComboBox>

I want the dropdown width to adjust itself to the width of the longest sentence or word in the dropdown items. How can I achieve this dynamically? I've tried setting DropDownAutoWidth to "Enabled", but it seems to adjust the width based on the width of the RadComboBox itself, not the content. Is there a way to achieve this without explicitly setting a fixed width?

Any help or guidance on how to achieve this functionality would be greatly appreciated. Thank you!

1

There are 1 answers

0
ClearlyClueless On

See this link on Telerik's documentation: Telerik RadComboBox AutoSizeDropdown

I see you are setting that property on the control itself, however you have applied width and a css class. Both of those can be interfering with the autosizing of the dropdown and should be removed to test.