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

RADCalendar - EditorPart ApplyChanges() function is called after CreateChildControls() function of WebPart class

1 Answer 54 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
LJ
Top achievements
Rank 1
LJ asked on 23 Oct 2009, 07:48 AM

Hi All,

I have a custom web part which includes RAD Chart.
Chart is created dynamically as per the web part configuration settings.
I have custom editor part to set chart specific configuration settings.

I set configration settings and click on Apply/OK button and chart is created accordingly.

But if I add RADCalendar control in web part, and then set configuration settings and click on Apply button, chart is not created accordingly. It did not changed. If I again click on Apply button, then chart is created as per the configuration settings done.

i.e. as i add RADCalendar in web part, i need to click on apply button two times to reflect the configuration settings changes in RADChart.

I tried to figure out what is happening:

case 1 : RADCalendar is not added in web part

Following is the sequence of functions call as I click on Apply button:

1. OnInit (WebPart class)
2. CreateChildControls (EditorPart class)
3. ApplyChanges (EditorPart class)
4. SyncChanges (EditorPart class)
5. CreateChildControls (WebPart class)
6. OnPreRender (EditorPart class)
7. RenderContents (WebPart class)
8. RenderContents (EditorPart class)

Case 2: RADCalendar is added in web part

Following is the sequence of functions call as I click on Apply button:

1. OnInit (WebPart class)
2. CreateChildControls (EditorPart class)
3. CreateChildControls (WebPart class)
4. ApplyChanges (EditorPart class)
5. SyncChanges (EditorPart class)
6. OnPreRender (EditorPart class)
7. RenderContents (WebPart class)
8. RenderContents (EditorPart class)

I have added controls in web part class in CreateChildControls function.

Please refer the following code for details:

****************************************************************************
protected override void CreateChildControls()     
{   
try     
{   
base.CreateChildControls();    
// Clear any existing child controls.     
Controls.Clear();  
 
RadCalendar calendar = new RadCalendar();   
calendar.ID = "calendar";   
calendar.EnableViewState = false;   
this.Controls.Add(calendar);   
 
// Create a panel that will hold chart control.   
Panel cvWebPartPanel = new Panel();   
// Create Telerik RadChart control   
RadChart radChart = CreateRadChartControl();   
// Check if radChart is not null, then add it to the panel.   
if (radChart != null)   
{  
cvWebPartPanel.Controls.Add(radChart);  
}  
 
// Add the panel to the controls collection of the web part.   
this.Controls.Add(cvWebPartPanel);   
   
// Prevent child controls from being created again.   
this.ChildControlsCreated = true;   
}  
catch (Exception)   
{  
this.Controls.Clear();   
this.Controls.Add(new LiteralControl("Error"));   
}  
}  
 

****************************************************************************

My observation is that if I add RADCalendar then sequence of function call is changed. and CreateChildControls() function of webPart class is called before the ApplyChanges() function of EditorPart class. that is why changes in configuration settings did not get reflect in chart. chart has already been created with old values.

Please suggest me a solution and let me know why sequence of function call is changed.

Thank you!!

1 Answer, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 28 Oct 2009, 09:08 AM
Hello LJ,

Based on the supplied information, it is hard to determine what is causing this unwanted behavior. If the issue persists, you can open a formal support ticket, and send us a small working project, demonstrating your logic, and showing the unwanted behavior. We will debug it locally, and advise you further.

Regards,
Yavor
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.
Tags
Chart (Obsolete)
Asked by
LJ
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Share this question
or