Hello ,
i read a lot of Posts in the Forum but can't find a answer for the Problem.
I want to set a default empty ListItem into the RadCombo, which is loaded on demand.
The Empty Item should have a string.Empty as Text and the DataKey Type MinValue of the binded datasource as value.
For example
Text = string.Empty
Value = Guid.Empty().ToString()
or
Text = string.Empty
Value = int.MinValue.ToString()
Before I updated to the current Version (q1 2009) I used the Q3 2008 Version and all works as it should. Now I have the Problem that the Item is shown in the Combobox, but it is not selectable with a Mouse Click ?! I can Select It with Key Up/Down only, but that ist a help.
Just If I set the Text Like "------" or any other Text....
This is not what I want because a Empty Item should be really empty...
I read the workarround in this Forum but I want to set the empty with no Text = string.Empty.
Is It possible to undo the changes on this in the next version?
Kind Regards
Fabian
i read a lot of Posts in the Forum but can't find a answer for the Problem.
I want to set a default empty ListItem into the RadCombo, which is loaded on demand.
The Empty Item should have a string.Empty as Text and the DataKey Type MinValue of the binded datasource as value.
For example
Text = string.Empty
Value = Guid.Empty().ToString()
or
Text = string.Empty
Value = int.MinValue.ToString()
Before I updated to the current Version (q1 2009) I used the Q3 2008 Version and all works as it should. Now I have the Problem that the Item is shown in the Combobox, but it is not selectable with a Mouse Click ?! I can Select It with Key Up/Down only, but that ist a help.
Just If I set the Text Like "------" or any other Text....
This is not what I want because a Empty Item should be really empty...
I read the workarround in this Forum but I want to set the empty with no Text = string.Empty.
Is It possible to undo the changes on this in the next version?
Kind Regards
Fabian
5 Answers, 1 is accepted
0
Hello Fabian,
In order to confirm this as a bug I tried reproducing it with the following RadComboBox:
| <telerik:RadComboBox ID="RadComboBox1" runat="server" AutoPostBack="true"> |
| <Items> |
| <telerik:RadComboBoxItem runat="server" Text="" Value="1" /> |
| <telerik:RadComboBoxItem runat="server" Text="2" Value="2" /> |
| </Items> |
| </telerik:RadComboBox> |
and the latest version of Telerik.Web.UI - the first Item selected as it should.
Could you provide the full definition of your RadComboBox?
Kind regards,
Simon
the Telerik team
Instantly find answers to your questions on the newTelerik Support Portal.
Check out the tipsfor optimizing your support resource searches.
Kind regards,
Simon
the Telerik team
Instantly find answers to your questions on the newTelerik Support Portal.
Check out the tipsfor optimizing your support resource searches.
0
Fabian
Top achievements
Rank 1
answered on 02 Jun 2009, 07:43 AM
| <telerik:RadComboBox ID="ddlDropdown" runat="server" Skin="Default" Height="190px" |
| AllowCustomText="True" ShowToggleImage="True" ShowMoreResultsBox="true" AutoPostBack="false" |
| EnableLoadOnDemand="True" MarkFirstMatch="false" |
| EnableVirtualScrolling="true" Width="206px" DropDownWidth="450"> |
| </telerik:RadComboBox> |
| protected void DropDown_LoadItems(int iNumItems, string sFilter, Telerik.Web.UI.RadComboBox targetCombobox, RadComboBoxItemsRequestedEventArgs e) |
| { |
| try |
| { |
| if (DataSource != null) |
| { |
| string RowFilter = string.Empty; |
| if (((List<RowFilterObject>)RowFilterList).Count > 0) |
| RowFilter = RowFilterObject.GetRowFilter((List<RowFilterObject>)RowFilterList); |
| DataSource.DefaultView.RowFilter = (!string.IsNullOrEmpty(RowFilter)) ? "(" + RowFilter + ")" : RowFilter; |
| string[] distinctParams = new string[] { |
| DataValueField,DataTextField }; |
| DataTable distinctValues = DataSource.DefaultView.ToTable(true, distinctParams).Copy(); |
| distinctValues.DefaultView.Sort = DataTextField + " ASC"; |
| if (EmptyItemEnabled) |
| { |
| DataRow emptyrow = distinctValues.NewRow(); |
| if (distinctValues.Columns[DataValueField].DataType == typeof(Guid)) |
| { |
| emptyrow[DataValueField] = Guid.Empty; |
| } |
| else if (distinctValues.Columns[DataValueField].DataType == typeof(byte)) |
| { |
| emptyrow[DataValueField] = byte.MinValue; |
| } |
| else if (distinctValues.Columns[DataValueField].DataType == typeof(int)) |
| { |
| emptyrow[DataValueField] = int.MinValue; |
| } |
| else if (distinctValues.Columns[DataValueField].DataType == typeof(string)) |
| { |
| emptyrow[DataValueField] = string.Empty; |
| } |
| emptyrow[DataTextField] = string.Empty(); |
| distinctValues.Rows.InsertAt(emptyrow, 0); |
| } |
| LoadItems_CallbackMode(iNumItems, sFilter, targetCombobox, distinctValues.DefaultView.ToTable(), DataTextField, DataValueField, e); |
| } |
| else |
| { |
| e.Message = "DataContext lost / Sessionend"; |
| return; |
| } |
| } |
| catch (Exception ex) |
| { |
| base.Page.ShowError(ex.ToString()); |
| } |
| } |
| protected static void LoadItems_CallbackMode(int iNumItems, string sFilter, Telerik.Web.UI.RadComboBox comboBox, DataTable comboboxData, string DataTextField, string DataValueField, RadComboBoxItemsRequestedEventArgs e) |
| { |
| try |
| { |
| if (comboboxData != null) |
| { |
| ArrayList arRows = sFilter.Length > 0 ? new ArrayList(comboboxData.Select(DataTextField + " LIKE '%" + sFilter + "%' OR " + DataTextField + " LIKE '" + sFilter + "%'")) : new ArrayList(comboboxData.Rows); |
| int itemsPerRequest = iNumItems; |
| int itemOffset = e.NumberOfItems; |
| int endOffset = itemOffset + itemsPerRequest; |
| if (endOffset > arRows.Count) |
| { |
| endOffset = arRows.Count; |
| } |
| if (endOffset == arRows.Count) |
| { |
| e.EndOfItems = true; |
| } |
| else |
| { |
| e.EndOfItems = false; |
| } |
| for (int i = itemOffset; i < endOffset; i++) |
| { |
| RadComboBoxItem intialItem = comboBox.FindItemByValue(((DataRow)arRows[i])[DataValueField].ToString()); |
| if (intialItem != null) |
| comboBox.Items.Remove(intialItem); |
| comboBox.Items.Add(new RadComboBoxItem(((DataRow)arRows[i])[DataTextField].ToString(), ((DataRow)arRows[i])[DataValueField].ToString())); |
| } |
| if (arRows.Count > 0) |
| { |
| e.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), arRows.Count.ToString()); |
| } |
| else |
| { |
| comboBox.Text = string.Empty; |
| comboBox.SelectedValue = string.Empty; |
| comboBox.Items.Clear(); |
| e.Message = "No matches"; |
| } |
| } |
| else |
| e.Message = "No Databind"; |
| } |
| catch |
| { |
| e.Message = "No matches"; |
| } |
| } |
0
Hello Fabian ,
All the best,
Simon
the Telerik team
Instantly find answers to your questions on the newTelerik Support Portal.
Check out the tipsfor optimizing your support resource searches.
Thank you for providing the code.
Since your server-side logic depends on a data base, I tried reproducing the issue only with the ComboBox definition - still the Item with empty Text selected properly with the mouse.
| <telerik:RadComboBox ID="ddlDropdown" runat="server" Height="190px" |
| AllowCustomText="True" |
| Width="206px" DropDownWidth="450px"> |
| <Items> |
| <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem1" Value="1" /> |
| <telerik:RadComboBoxItem runat="server" Value="2" /> |
| <telerik:RadComboBoxItem runat="server" Text="RadComboBoxItem3" Value="3" /> |
| </Items> |
| </telerik:RadComboBox> |
Could you reproduce the issue with static Items?
All the best,
Simon
the Telerik team
Instantly find answers to your questions on the newTelerik Support Portal.
Check out the tipsfor optimizing your support resource searches.
0
Fabian
Top achievements
Rank 1
answered on 17 Jun 2009, 11:12 AM
Hello,
with static Items there is no Problem, but that not really helps for my case ;)
Kind Regards
Fabian
with static Items there is no Problem, but that not really helps for my case ;)
Kind Regards
Fabian
0
Hi Fabian ,
This means that the data coming from your data base is causing the issue.
Could you verify what data is returned and paste some of it here, so that test with it at my side and hopefully reproduce the issue?
All the best,
Simon
the Telerik team
Instantly find answers to your questions on the newTelerik Support Portal.
Check out the tipsfor optimizing your support resource searches.
All the best,
Simon
the Telerik team
Instantly find answers to your questions on the newTelerik Support Portal.
Check out the tipsfor optimizing your support resource searches.