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

Link in RadComboBox - ASP

10 Answers 149 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Eva
Top achievements
Rank 1
Eva asked on 08 Jan 2009, 08:54 PM
Hi,

Is there any way we can add tool tip or link  in RadComboBox .

In my situation ,when the user search ,if the value or information is not available, i need to show a link in Dropdown says 'Add New' ,when they click ,rad window or tooltip has to open.

Is there any way to achieve this behavior (ASP).

Thanks in Advance.
Eva


 

10 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 09 Jan 2009, 06:49 AM
Hi Eva,

I suggest you use Templates to achieve this functionality.

Kind regards,
Yana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Eva
Top achievements
Rank 1
answered on 09 Jan 2009, 06:23 PM
Hi Yana,

Could you please provide some code sample with this scenario.

When the user search in RadComboBox box ,if the value or information is not available, it need to show a link in Dropdown says 'Add New' ,when they click ,rad window or tooltip has to open.

Thanks.
Eva


0
Yana
Telerik team
answered on 12 Jan 2009, 01:57 PM
Hello Eva,

Please check the attached sample page which shows the needed approach. 
This code library demonstrates how you can reload RadComboBox from RadWindow.

Kind regards,
Yana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Eva
Top achievements
Rank 1
answered on 13 Jan 2009, 12:06 AM
Hi Yana ,

Thank you so much .

Could you please tell me how to open radtooltip instead of radwindow ,when user click 'Add New' link.

I tried couple of thinks but it doesn't work.

I appriciate your help.

Thanks you so much.

Eva
0
Yana
Telerik team
answered on 13 Jan 2009, 01:37 PM
Hello Eva,

Please add the tooltip to your page:

<telerik:RadToolTip ID="RadToolTip1" runat="server">  
    test tooltip  
</telerik:RadToolTip> 

and open it in OpenWindow function like this:

function openWindow()  
{  
   var combo = $find("<%=RadComboBox1.ClientID %>");  
   combo.set_value("");  
   var item = combo.findItemByValue("-1");  
   var radToolTip = $find("<%=RadToolTip1.ClientID %>");  
   radToolTip.set_targetControl(item.get_element());  
   radToolTip.show();                

Best regards,
Yana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Eva
Top achievements
Rank 1
answered on 14 Jan 2009, 11:53 PM
Hi Yana ,

Thank you so much , It works.

But my radtooltip has controls like textbox. When i clicked textbox it closes tooltip and combobox.

Here is my code

<telerik:RadComboBox runat="server" id="rcPartNumber"  Width="130px"  Font-Names="Arial" Font-Size="XX-Small" AutoPostBack="true" DataTextField="Name" Height="100px"  CloseDropDownOnBlur="true"
                                DataValueField="ItemTypesId"   EnableLoadOnDemand="True"     AllowCustomText="true" MarkFirstMatch="true"  
                                OnClientSelectedIndexChanging="selectedIndexChanging" OnItemsRequested="rcPartNumber_ItemsRequested"     >
                               </telerik:RadComboBox> 


 <telerik:RadToolTip runat="server" ID="RadToolTip2" ShowEvent="OnClick" ShowDelay="0"
                                HideEvent="ManualClose" Position="MiddleRight" RelativeTo="Element"  
                                Animation="Fade"  TargetControlID="btnAddPartNumber" >
                                        <table>
                                            <tr>
                                                <td><asp:Label ID="lblPartNumberTt"  CssClass="DataTitle" runat="server" Text="Model / PN:" ></asp:Label></td>
                                                <td><asp:TextBox ID="txtPartNumberTt" runat="server" ></asp:TextBox></td>
                                            </tr>
</table>
</telerik:RadToolTip >


Is there anything i am missing.
Thanks.
Eva


0
Yana
Telerik team
answered on 15 Jan 2009, 03:25 PM
Hello Eva,

Thank you for getting back to me.

Please modify selectedIndexChanging method like this:

function selectedIndexChanging(sender, args)  
{  
    if(args.get_item().get_value() == "-1")  
    {  
        args.set_cancel(true);  
        sender.set_value("-1");  
    }  

and also subscribe RadComboBox to OnClientDropDownOpening with the following handler:

function dropDownClosing(sender, args)  
{  
    if(sender.get_value() == "-1")  
        args.set_cancel(true);  

RadToolTip is not supposed to close as you set HideEvent property to ManualClose.

All the best,
Yana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Eva
Top achievements
Rank 1
answered on 15 Jan 2009, 07:30 PM
Hi Yana,

It doesn't work.

Here is my code.

 function openWindow() {
            var combo = $find("<%=rcPartNumber.ClientID %>");
            combo.set_value("");
            var item = combo.findItemByValue("-1");
            var radToolTip = $find("<%=RadToolTip2.ClientID %>");
            radToolTip.set_targetControl(item.get_element());
            radToolTip.show();
        }
        function selectedIndexChanging(sender, args) {
            if (args.get_item().get_value() == "-1") {
                args.set_cancel(true);
                sender.set_value("-1");
            }
        }
        function dropDownClosing(sender, args) {
           
            if (sender.get_value() == "-1") {
                args.set_cancel(true);
                            }
        } 


 <telerik:RadComboBox runat="server" id="rcPartNumber"  Width="130px"  Font-Names="Arial" Font-Size="XX-Small" AutoPostBack="true" DataTextField="Name" Height="100px"  
                                DataValueField="ItemTypesId"   EnableLoadOnDemand="True"     AllowCustomText="true" MarkFirstMatch="true"  
                                OnClientSelectedIndexChanging="selectedIndexChanging"  OnClientDropDownOpening="dropDownClosing" >
                               </telerik:RadComboBox>



Protected Sub rcPartNumber_ItemsRequested(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs) Handles rcPartNumber.ItemsRequested
        Dim PartNumber = From p In db.ItemTypes.AsEnumerable() _
                         Where p.Name.Contains(e.Text) _
                        Select p      
       
        Dim data As New DataTable()
        'data.Load(PartNumber)
        Try
            Dim itemsPerRequest As Integer = 10
            Dim itemOffset As Integer = e.NumberOfItems
            Dim endOffset As Integer = itemOffset + itemsPerRequest
            If endOffset > data.Rows.Count Then
                endOffset = data.Rows.Count
            End If
            If endOffset = data.Rows.Count Then
                e.EndOfItems = True
            Else
                e.EndOfItems = False
            End If
            For i As Integer = itemOffset To endOffset - 1
                ' RadComboBox1.Items.Add(New RadComboBoxItem(data.Rows(i)("CompanyName").ToString(), data.Rows(i)("CompanyName").ToString()))
            Next

            If data.Rows.Count > 0 Then
                e.Message = [String].Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), data.Rows.Count.ToString())
            Else
                e.Message = "No matches"

                Dim lbl As New Label()
                lbl.ID = "link"
                lbl.Text = "Add new"

                lbl.Attributes.Add("OnClick", "javascript:openWindow(); return false;")
                Dim item As New RadComboBoxItem("addnew", "-1")
                item.Controls.Add(lbl)
                rcPartNumber.Items.Add(item)
                'RadToolTip2.TargetControlID = item.ClientID
                ' RadToolTip2.TargetControlID = item.ClientID
            End If
        Catch
            e.Message = "No matches"
        End Try
    End Sub

Am i missing anything.
Thanks.
Eva
0
Yana
Telerik team
answered on 19 Jan 2009, 11:25 AM
Hello Eva,

I tested again and really in some cases the dropdown is closed.  Since I am not able to understand when exactly it' closed, I think the best solution is to make RadToolTip modal, so the other area cannot be clicked at all. You just have to set Modal property of the tooltip to true. Please let us know whether this is suitable for you.  

Best Regards,
Yana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Eva
Top achievements
Rank 1
answered on 19 Jan 2009, 06:16 PM

Hi Yana,

I tried the Modal ,it doesn't help.

Any how thanks for all your help.

Eva
Tags
ComboBox
Asked by
Eva
Top achievements
Rank 1
Answers by
Yana
Telerik team
Eva
Top achievements
Rank 1
Share this question
or