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

RadGrid in ToolTip on RadGrid

11 Answers 139 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Stefan Stanescu
Top achievements
Rank 1
Stefan Stanescu asked on 30 Nov 2009, 09:46 AM
Hi all

The page I'm doing is a little complicated but I will try to explain what I need to achieve.
1. On the page there is an UpdatePanel ("upTimeRegs") with a RadGrid, where each row has an ID and a link.
2. When the mouse is over a link, a ToolTip ("ToolTipManager") should appear with contents based on the row's ID.
3. The content of the ToolTip is a user control ("ucTimeRegistrations") with another RadGrid ("RadGridTimeRegistrations") which has it's data bound in the NeedDataSource event handler
4. In the second RadGrid one of the columns is a RadComboBox. For each RadComboBox OnSelectedIndexChanged the main RadGrid should be updated

The problems I have:
1. The ToolTip is loaded fine the first time the mouse is over a link, but then when I hover a second link the content of the tooltip is not changed because the NeedDataSource event is not triggered.

2. The main RadGrid is not being updated when the selected index of a combobox is changed.

Here is some of the code I'm using:
protected void ToolTipManager_OnAjaxUpdate(object sender, ToolTipUpdateEventArgs args) 
    Control ctrl = Page.LoadControl("~/UserControls/ucTimeRegistrations.ascx"); 
    args.UpdatePanel.ContentTemplateContainer.Controls.Add(ctrl); 
    ucTimeRegistrations TimeRegistrations = (ucTimeRegistrations)ctrl; 
    TimeRegistrations.TaskID = Convert.ToInt32(args.Value); 
 
 
 
public partial class ucTimeRegistrations : UserControl 
    public int TaskID; 
    protected void Page_Load(object sender, EventArgs e) 
    { 
    } 
 
    protected void RadGridTimeRegistrations_NeedDataSource(object  source, GridNeedDataSourceEventArgs e) 
    { 
        RadGTimeRegistrations.DataSource = TimeRegistrationHandler.GetTimeRegistrationsFromDB(TaskID); 
    } 
 
    protected void RadComboBoxActivity_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e) 
    { 
        RadComboBox rcbActivity = (RadComboBox)sender; 
        GridDataItem Row = (GridDataItem)rcbActivity.Parent.Parent; 
        if (Row != null
        { 
            int TimeRegistrationID = Convert.ToInt32(Row["TimeRegistrationID"].Text); 
            int ActivityID = Convert.ToInt32(e.Value); 
            TimeRegistrationHandler.UpdateTimeRegistration(TimeRegistrationID, ActivityID); 
                 
            UpdatePanel upTimeRegs = (UpdatePanel) FindControlRecursive(Page, "upTimeRegs");
            upTimeRegs.Update(); 
        } 
    }

    private Control FindControlRecursive(Control rootControl, string Id)
    {
        if (rootControl.ID == Id)
            return rootControl;
        foreach (Control childControl in rootControl.Controls)
        {
            Control foundControl = FindControlRecursive(childControl, Id);
            if (foundControl != null) return foundControl;
        }
        return null;
    }
 


Thanks,
Stefan

11 Answers, 1 is accepted

Sort by
0
Stefan Stanescu
Top achievements
Rank 1
answered on 01 Dec 2009, 12:55 PM
Me again.

I fixed the first problem by rebinding the RadGrid in the PreRender event of the user control.
I couldn't rebind it in the PageLoad because it would prevent me from finding the item i selected in a combobox.

protected void Page_Load(object sender, EventArgs e) 
    this.PreRender+=OnPreRender; 
 
protected void OnPreRender(object sender, EventArgs e) 
    RadGridTimeRegistrations.Rebind(); 

One more to go :)


0
Stefan Stanescu
Top achievements
Rank 1
answered on 02 Dec 2009, 10:26 AM
There, I fixed it!


I needed to rebind the main RadGrid on the SelectedIndexChanged event before updating the UpdatePanel. I was missing the obvious.

One more quick tip: I had to place the RadToolTipManager outside of the UpdatePanel, because it was hiding after each selected index change.

Hope this will help others as well :)

All the best,
Stefan
0
Kevin
Top achievements
Rank 2
answered on 02 Dec 2009, 08:34 PM
Stefan,

I just wanted to say thanks for coming back and posting your findings - this will help me with a project I'm starting!

--Kdc
0
Stefan Stanescu
Top achievements
Rank 1
answered on 04 Dec 2009, 07:40 AM
I've been trying to determine what was causing my ToolTips not to be updated when I was sorting the main RadGrid and it seems like the small tip I've written in the previous post is kind of useless.
Actually, I had no choice but to place the RadToolTipManager back in the UpdatePanel with the RadGrid to solve this problem.

So here's my next problem: how do I make the ToolTip visible after postbacks, with the exact same contents it had before?


Stefan
0
Iana Tsolova
Telerik team
answered on 09 Dec 2009, 03:49 PM
Hello Stefan,

Have you tried setting the UpdatePanel wrapping the grid and the tooltip UpdateMode property to Conditional and see if it makes any difference?


All the best,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Stefan Stanescu
Top achievements
Rank 1
answered on 10 Dec 2009, 08:24 AM
Hi Iana,

Yes the UpdateMode is set to Conditional.

Just to make things clear I am using the Q2 2008 version of the controls.

Right now when the mouse is over a link in the main RadGrid the ToolTip is displayed correctly. Then if I click a button or change the selected index of a RadComboBox inside the ToolTip the main RadGrid gets updated as it should, but the ToolTip is no longer visible. The ToolTipManager has ManualClose="true" and Sticky="true" so I would like it to stay in place until I close it. I think this is the same as HideEvent="ManualClose" in the new version of RadToolTipManager.

I just need to know if this is the expected behavior of the RadToolTips. If so, what would be the best approach to make the ToolTip visible again? (otherwise, it's just a problem with my code and I'll post a solution as soon as I find it)

Best regards,
Stefan

0
Iana Tsolova
Telerik team
answered on 11 Dec 2009, 02:53 PM
Hello Stefan,

I tried follwoing your scenario and prepared a sample project for you. Could you please check it out and let me know what differs in your case?

Regards,
Iana
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Stefan Stanescu
Top achievements
Rank 1
answered on 11 Dec 2009, 04:56 PM
Hello Iana,

Thanks for your reply!

I tried the sample project but unfortunately I didn't find a solution for my problem.
I changed the RadGrid1_NeedDataSource event just a little bit, so we get new data every time we rebind the RadGrid (just added a date stamp to each row).

for (int i = 0; i < 50; i++) 
    table.Rows.Add(i, "Item" + i.ToString() + " " + DateTime.Now.ToString()); 

Then I added to the RadComboBox1_SelectedIndexChanged event the following code:

UpdatePanel UpdatePanel1 = (UpdatePanel)Page.FindControl("UpdatePanel1"); 
RadGrid RadGrid1 = (RadGrid)UpdatePanel1.ContentTemplateContainer.FindControl("RadGrid1"); 
RadGrid1.Rebind(); 
UpdatePanel1.Update(); 

This simulates the behavior of my application, because I need to update the data inside the RadGrid using the ToolTip.

The call to UpdatePanel1.Update(); is necessary because the RadToolTipManager creates it's own UpdatePanel (therefore we have one UpdatePanel inside another) and this is the only way that I know to update the outer UpdatePanel from a control inside the inner UpdatePanel.

With these changes the behavior is almost the same as with my application: the RadGrid gets updated but the ToolTip disappears.

There is an extra problem with this approach in the sample project, which I don't have in my app (probably because in my case the RadComboBox is inside the ItemTemplate of a GridTemplateColumn from a RadGrid): the RadComboBox1_SelectedIndexChanged event gets triggered twice every time - once when I select an item and once more probably because of UpdatePanel1.Update();
But as I said, this is only in this sample project.

I hope I didn't get you confused.

Best regards,
Stefan
0
Stefan Stanescu
Top achievements
Rank 1
answered on 11 Dec 2009, 05:00 PM
I have no idea why the background is gray on the previous post XD

<div style="color:Red;">
I wonder if the editor has also support for html.
<div>

Update: seems not
0
Iana Tsolova
Telerik team
answered on 14 Dec 2009, 12:03 PM
Hi Stefan,

Thank you for the additional information provided.

I followed you description and was able to replicate the unexpected behavior on my side. In order to overcome this issue I suggest that you first close the tooltip when item is selected from the combobox and then update the grid. Please check the attached for additional details and let me know if this works for you. 


All the best,
Iana
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Stefan Stanescu
Top achievements
Rank 1
answered on 26 Jan 2010, 10:12 AM
YES!!!

I finally found out how to make the RadToolTip reappear after a postback.
It turns out that all I had to do was to set the RadToolTip's VisibleOnPageLoad property to "true".

Thanks for your great support! Problem solved!

Tags
Grid
Asked by
Stefan Stanescu
Top achievements
Rank 1
Answers by
Stefan Stanescu
Top achievements
Rank 1
Kevin
Top achievements
Rank 2
Iana Tsolova
Telerik team
Share this question
or