Hello everybody,
I have a problem with setting the DropDownWidth property from server-side.
I use RadComboBox as a FilterTemplate on my RadGrid.
this is what I launch when I click RadComboBox:
and I checked that the code properly changed the DropDownWidth property but the size of the DropDown is still the same.
I believe I've put the code in wrong place.
I tried using the code from:
http://www.telerik.com/community/code-library/aspnet-ajax/combobox/dynamic-dropdown-width.aspx
but it didn't work. It ran 2 times (don't know why).
During 1st time It doesn't find any Items in RadComboBox so it's setting the DropDownWidth as 155px (initial value from code).
During 2nd time it found all elements and calculated the proper width. It did set the property but on page it was still visible as 155px.
Here's my ComboBox code:
I have a problem with setting the DropDownWidth property from server-side.
I use RadComboBox as a FilterTemplate on my RadGrid.
this is what I launch when I click RadComboBox:
protected void list_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e) { Current_rcb_Width = 0; if (((RadComboBox)o).DataTextField == "nazwa_") ((RadComboBox)o).DataSource = GetDataTable("SELECT DISTINCT " + ((RadComboBox)o).DataTextField + jezyk + " as nazwa_ FROM katalog_produktow WHERE " + ((RadComboBox)o).DataTextField + jezyk + " LIKE '" + e.Text + "%' order by " + ((RadComboBox)o).DataTextField + jezyk); else ((RadComboBox)o).DataSource = GetDataTable("SELECT DISTINCT " + ((RadComboBox)o).DataTextField + " FROM katalog_produktow WHERE " + ((RadComboBox)o).DataTextField + " LIKE '" + e.Text + "%' order by " + ((RadComboBox)o).DataTextField); var cbox = ((RadComboBox)o); int MaxWidth = 0; foreach (DataRow row in (((RadComboBox)o).DataSource as DataTable).Rows) { int Width = TextWidth(row[((RadComboBox)o).DataTextField].ToString()); if (Width > MaxWidth) { MaxWidth = Width; } } cbox.DropDownWidth = new Unit(MaxWidth); ((RadComboBox)o).DataBind(); }and I checked that the code properly changed the DropDownWidth property but the size of the DropDown is still the same.
I believe I've put the code in wrong place.
I tried using the code from:
http://www.telerik.com/community/code-library/aspnet-ajax/combobox/dynamic-dropdown-width.aspx
but it didn't work. It ran 2 times (don't know why).
During 1st time It doesn't find any Items in RadComboBox so it's setting the DropDownWidth as 155px (initial value from code).
During 2nd time it found all elements and calculated the proper width. It did set the property but on page it was still visible as 155px.
Here's my ComboBox code:
<telerik:RadComboBox ID="rcbnazwa" runat="server" ShowToggleImage="false" EnableLoadOnDemand="true" OnItemsRequested="list_ItemsRequested" OnDataBound="RadComboBox1_DataBound" MarkFirstMatch="true" Skin="Office2007" OnSelectedIndexChanged="rcbContinents_SelectedIndexChanged" DataTextField="nazwa_" Font-Size="X-Small" DataValueField="nazwa_" OnPreRender="rcbContinents_PreRender" AutoPostBack="true" Width="100%"> </telerik:RadComboBox>