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

Loaded event

6 Answers 124 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Louis Bouchard
Top achievements
Rank 1
Louis Bouchard asked on 09 May 2011, 10:54 PM
Unlike the toolkit:DataForm, the RadDataForm not trigger the Loaded event of a TextBox when I move to another record...

<telerik:DataFormDataField Grid.Row ="0" Grid.Column="0"  Width="250" HorizontalAlignment="Left" Label="{Binding Source={StaticResource LocalisationTachesARisque}, Path=NameNoTache}" IsEnabled="False" >
    <telerik:DataFormDataField.ContentTemplate>
        <DataTemplate>
            <TextBox Text="{Binding NoTache, Mode=TwoWay, NotifyOnValidationError=False}"  Margin="-10,0,0,0" Loaded="TextBox_Loaded_1"/>
        </DataTemplate>
    </telerik:DataFormDataField.ContentTemplate>
</telerik:DataFormDataField>


Any idea to fired this event????

6 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 10 May 2011, 10:09 AM
Hi Louis Bouchard,

RadDataForm reuses its data fields, when its current item changes, so they are never excluded from the visual tree. Consequently their loaded events are raised once.  I would advise you to subscribe to another event in order to accomplish your tasks. As for this very case, you may try subscribing to TextBox's TextChanged event.

Greetings,
Ivan Ivanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Louis Bouchard
Top achievements
Rank 1
answered on 10 May 2011, 01:51 PM
Hello Ivan,

Thany you for this information.  I really appreciate.

About the RadRichTextBox, I need to do some operation every time when I goto to the next record (via RadDataForm) :

<telerik:DataFormDataField x:Name="DataFormDataFieldNote"  Grid.Row ="1" Grid.Column="0" Grid.ColumnSpan="2" Width="800" HorizontalAlignment="Left"  Label="{Binding Source={StaticResource LocalisationTachesARisque}, Path=NameNote}" IsEnabled="False"  >
    <telerik:DataFormDataField.ContentTemplate>
        <DataTemplate>
            <telerik:RadRichTextBox  x:Name="richTextBox" Width="690" Height="250"   LayoutMode="FlowNoWrap" Margin="-195,0,0,0" BorderBrush="#a1acb7"  BorderThickness="1" Background="#ebebeb" IsReadOnly="True"  IsSpellCheckingEnabled="False" IsSelectionMiniToolBarEnabled ="False"  IsContextMenuEnabled="False" Loaded="richTextBox_Loaded" >
                <telerik:RadRichTextBox.Resources>
                    <telerikHtml:HtmlDataProvider x:Key="htmlDataProvider" RichTextBox="{Binding ElementName=richTextBox}"  Html="{Binding Body, Mode=TwoWay}" />
                </telerik:RadRichTextBox.Resources>
            </telerik:RadRichTextBox>
        </DataTemplate>
    </telerik:DataFormDataField.ContentTemplate>
</telerik:DataFormDataField>

Best regards
0
Ivan Ivanov
Telerik team
answered on 10 May 2011, 02:44 PM
Hi Louis Bouchard,

You may try this approach to access this RadRichTextBox from the code-behind:
public MainPage()
        {
            InitializeComponent();
            testDataForm.CurrentItemChanged += new EventHandler<EventArgs>(testDataForm_CurrentItemChanged);
        }
  
        void testDataForm_CurrentItemChanged(object sender, EventArgs e)
        {            
            testDataForm.ChildrenOfType<RadRichTextBox>().First();
        }


Regards,
Ivan Ivanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Ivan Ivanov
Telerik team
answered on 10 May 2011, 02:53 PM
Hi Louis Bouchard,

Just to add something to my previous post. If you want to find this RadRichTextBox by its Name property (we suppose that you have more than one RadRichTextBoxes in your template), you may change the previous LINQ query like this:
testDataForm.ChildrenOfType<RadRichTextBox>().Where(rtb => rtb.Name == "richTextBox").First();


Regards,
Ivan Ivanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Louis Bouchard
Top achievements
Rank 1
answered on 11 May 2011, 07:17 PM
A big thank you.  It's really help.

Have nice day.
0
Almond
Top achievements
Rank 1
answered on 16 Aug 2011, 12:07 PM
Hi Ivan,

Good evening.

Would like to ask if the same can also be implemented with the RadComboBox inside a RadDataForm.  I am having a hard time in trying to display the 1st Value of the  child RadComboBox inside a dataform. Basically what i am trying to implement is a cascading RadComboBox which will display the 1st value of the child RadComboBox filtered based on the SelectedValue of the parent RadComboBox.  Oh, by the way the child RadComboBox are being populated with the correct data. I would really really just like to display the 1st value from that populated child RadComboBox.

I tried to implement it however, it always results into null.  I have the below codes:
<telerik:RadDataForm.EditTemplate>
  <DataTemplate>
    <StackPanel>
      <Grid x:Name="DataFormGrid" Margin="2,15,2,2">
        <!--Company DS-->
          <ex:ComboBoxDataSource x:Name="companyDS" DomainContext="{StaticResource aimsDC}"
                                                   OperationName="GetTbl_companyQuery" Margin="518,429,68,12"
                                                   LoadCompleted="companyDS_LoadCompleted"/>
 
        <!--Department DS-->
          <ex:ComboBoxDataSource x:Name="departmentDS" DomainContext="{StaticResource aimsDC}"
                                                   OperationName="GetTbl_departmentByCompIDQuery"
                                                   Margin="578,429,12,12" LoadCompleted="departmentDS_LoadCompleted">
                                <ex:ComboBoxDataSource.Parameters>
                                    <ex:Parameter ParameterName="compIDNo" Value="{Binding SelectedValue, ElementName=companyCbo}" />
                                </ex:ComboBoxDataSource.Parameters>
                            </ex:ComboBoxDataSource>
 
                            <dataForm:DataField Label="" Margin="6,3,0,2"
                                                Grid.Column="3" >
                                <telerik:RadComboBox x:Name="companyCbo" DisplayMemberPath="comp_abbr"
                                                     FlowDirection="LeftToRight" Margin="1,0,0,0"
                                                     Grid.Column="5" Grid.Row="0" Height="23"
                                                     HorizontalContentAlignment="Left"
                                                     ItemsSource="{Binding Data, ElementName=companyDS}"
                                                     SelectedValue="{Binding rsdtls_company, Mode=TwoWay}"
                                                     SelectedValuePath="comp_id"
                                                     ex:ComboBox.Mode="AsyncEager" TabIndex="2"
                                                     SelectionChanged="companyCbo_SelectionChanged"
                                                     DropDownClosed="companyCbo_DropDownClosed"
                                                     />
                            </dataForm:DataField>
 
                            <!--Department Combo Box-->
                            <dataForm:DataField Label="" Margin="0,3,13,2"
                                                Grid.Column="6" >
                                <telerik:RadComboBox x:Name="departmentCbo" DisplayMemberPath="dept_desc"      
                                  FlowDirection="LeftToRight" Margin="1,0,0,0" Grid.Column="5" Grid.Row="0" Height="23"
                                  HorizontalContentAlignment="Left" ItemsSource="{Binding Data, ElementName=departmentDS}"
                                  SelectedValue="{Binding dept_idno, Mode=TwoWay}"                                  
                                  SelectedValuePath="dept_idno" ex:ComboBox.Mode="AsyncEager" TabIndex="2"
                                  SelectionChanged="departmentCbo_SelectionChanged"/>
                            </dataForm:DataField>
                        </Grid>
                    </StackPanel>
                </DataTemplate>
            </telerik:RadDataForm.EditTemplate>
        </telerik:RadDataForm>

And I am trying to assing get the object reference in the code behind of the departmentDS_LoadCompleted.

Can you help me in my problem. I have been looking for possible solutions but i cant seem to find a appropriate one.  I have been back and forth in forums for days now and I cant find any clear cut solution and it seems to me that this is the closest.  Oh btw, when i tried the code:
      RadComboBox currentCbo = ((RadComboBox)sender).FindName("departmentCbo") as RadComboBox;
it works when it is inside a RadComboBox SelectionChanged event but if its inside the department_LoadCompleted, I cant seem to run the code successufully even if i change the sender to a Telerik.Windows.Cotrols.RadComboBox().

Hope to hear from you and thanks in advance.

almond
Tags
DataForm
Asked by
Louis Bouchard
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Louis Bouchard
Top achievements
Rank 1
Almond
Top achievements
Rank 1
Share this question
or