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

Open RadDataForm in Add new Item Mode

3 Answers 302 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Nelson
Top achievements
Rank 1
Nelson asked on 09 Aug 2011, 10:28 AM
Hi,

Is possible have a DataForm open in Add new Item template, without click in any button?

Thanks

3 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 09 Aug 2011, 11:54 AM
Hi Nelson,

You may try invoking AddNewItem() on RadDataForm's Loaded event. Please, refer to the attached project.

Kind regards,
Ivan Ivanov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
0
Nelson
Top achievements
Rank 1
answered on 10 Aug 2011, 09:04 AM
Hi,

Thanks for the reply.

I did what you said, but doesn´t work. I have this code in my XAML.

<DataTemplate x:Key="Adicionar">
            <!--<StackPanel Margin="10,1,0,0">-->
                <Grid Name="GrdPrincipal">
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>
 
                <Grid Grid.Row="0" Height="190">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
 
                        <Grid Grid.Column="0" Margin="5" >
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="0.3*"/>
                                <ColumnDefinition Width="0.7*"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
 
                            <TextBlock Grid.Column="0" Grid.Row="0" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="-70,10,0,0"                     Text="Designação:" telerik:StyleManager.Theme="{Binding Path=DataContext.Tema, ElementName=LayoutRoot}" />
                            <TextBlock Grid.Column="0" Grid.Row="1" HorizontalAlignment="Right" VerticalAlignment="Center" Margin="-70,10,0,0"                    Text="Tipo Notificação:"     telerik:StyleManager.Theme="{Binding Path=DataContext.Tema, ElementName=LayoutRoot}" />
                            <TextBox   Grid.Column="1" Grid.Row="0" HorizontalAlignment="Left"  VerticalAlignment="Center" Margin="10,10,0,0" IsReadOnly="False" Text="{Binding DesignacaoProp, Mode=TwoWay}" Width="200" AcceptsReturn="True" telerik:StyleManager.Theme="{Binding Path=DataContext.Tema, ElementName=LayoutRoot}" MaxLength="50" />
                            <telerik:RadComboBox Grid.Column="1" Grid.Row="1" Width="200" MaxWidth="350" Height="20" HorizontalAlignment="Left" Margin="10,10,0,0"
                                                    ItemsSource="{Binding Path=DataContext.OCTiposNotificacao,ElementName=LayoutRoot}" DisplayMemberPath="DesignacaoProp"
                                                    Cursor="Hand" ToolTipService.ToolTip="Seleccionar Tipo de Notificação" />
                        </Grid>
                        <StackPanel Grid.Column="1" Margin="5">
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition/>
                                            <RowDefinition/>
                                        </Grid.RowDefinitions>
                                        <TextBlock  Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="0" Text="Participantes:" telerik:StyleManager.Theme="{Binding Path=DataContext.Tema, ElementName=LayoutRoot}" />
                                        <telerik:RadGridView
                                        Grid.Row="1" Margin="0 10 0 0"
                                        Name="GrdConvocados"
                                        Background="Transparent"
                                        ItemsSource="{Binding Path=DataContext.OCNotificacoesParticipantes,ElementName=LayoutRoot}"
                                        BorderThickness="0"
                                        HorizontalAlignment="Left" Width="300" MaxHeight="300" RowHeight="20" Height="Auto"
                                        AutoGenerateColumns="False"
                                        SelectionMode="Single"
                                        Cursor="Hand"
                                        RowIndicatorVisibility="Collapsed"
                                        IsFilteringAllowed="True"
                                        ShowGroupPanel="False"
                                        ShowColumnFooters="False" ShowInsertRow="False"
                                        telerik:RadDragAndDropManager.AllowDrop="True">
                                            <telerik:RadGridView.Columns>
                                                <telerik:GridViewDataColumn DataMemberBinding="{Binding ParticipantesreuniaoProp.EntidadesProp.TiposentidadeProp.DesignacaoProp}" Header="Tipo Entidade" Width="0.2*" IsReadOnly="True"/>
                                                <telerik:GridViewDataColumn DataMemberBinding="{Binding ParticipantesreuniaoProp.EntidadesProp,Converter={StaticResource ConcatenaTitulo}}" Header="Nome" Width="0.6*" IsReadOnly="True"/>
                                                <telerik:GridViewCheckBoxColumn DataMemberBinding="{Binding Selecionado}" Header="Selec." Width="0.2*" IsReadOnly="false"/>
                                            </telerik:RadGridView.Columns>
                                        </telerik:RadGridView>
                                    </Grid>
                                </StackPanel>
                             
                    </Grid>
                    <Grid Grid.Row="1" Name="grdWord" Width="Auto">
                        <UC:SGAControloWord  HorizontalAlignment="Center" VerticalAlignment="Bottom" Height="Auto" Margin="0,40,0,10"/>
                        <telerik:RadExpander x:Name="radExpanderVisualizarNotificacao" Margin="0,0,20,0"
                             HorizontalAlignment="Right"
                             IsExpanded="False" ExpandDirection="Left"
                             Background="Transparent"
                             telerik:AnimationManager.IsAnimationEnabled="True" Cursor="Hand">
                            <telerik:RadExpander.Header>
                                <TextBlock Text="Importar Template de Notificação" FontSize="16" FontFamily="Tahoma"/>
                            </telerik:RadExpander.Header>
                            <telerik:RadExpander.Content>
                                <telerik:RadDocking Height="430" Width="915">
                                    <telerik:RadDocking.DocumentHost>
                                        <telerik:RadSplitContainer>
                                            <telerik:RadPaneGroup x:Name="docHostSplitContainer">
                                                <telerik:RadDocumentPane x:Name="painelReuniao" CanFloat="False" CanUserClose="False" CanUserPin="False" PaneHeaderVisibility="Collapsed" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Visibility="Collapsed">
                                                    <Grid Height="450" Width="915">
                                                    <UC:PrevisualizarTemplateNotificacao/>
                                                </Grid>
                                                </telerik:RadDocumentPane>
                                            </telerik:RadPaneGroup>
                                        </telerik:RadSplitContainer>
                                    </telerik:RadDocking.DocumentHost>
                                </telerik:RadDocking>
                            </telerik:RadExpander.Content>
                        </telerik:RadExpander>
                    </Grid>
                </Grid>
            <!--</StackPanel>-->
        </DataTemplate>
</UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="Transparent" Height="720" Width="1000">
        <telerik:RadDataForm x:Name="frmCriarNotificacao" Margin="0"  BorderThickness="1"
                             CommandButtonsVisibility="Commit, Cancel"
                             AutoGenerateFields="False" ItemsSource="{Binding OCNotificacoesParticipantes, Mode=TwoWay}"
                             Height="700" Width="970">
            <swi:Interaction.Triggers>
                <swi:EventTrigger EventName="Loaded">
                    <esi:CallDataMethod Method="FrmNotificacao_Loaded" />
                </swi:EventTrigger>
            </swi:Interaction.Triggers>
            <telerik:RadDataForm.ReadOnlyTemplate>
                <StaticResource ResourceKey="Adicionar"/>
            </telerik:RadDataForm.ReadOnlyTemplate>
            <telerik:RadDataForm.NewItemTemplate>
                <StaticResource ResourceKey="Adicionar"/>
            </telerik:RadDataForm.NewItemTemplate>
        </telerik:RadDataForm>

As you can see, I use a DataTemplate for my DataForm. What I want is make available the commit button, like in "new item mode".

And as you know, I can´t create only NewItemTemplate.

Any help please?

Thanks in advance
0
Ivan Ivanov
Telerik team
answered on 10 Aug 2011, 01:59 PM
Hi Nelson,

Obviously I have misunderstood your requirements. Would you please give us a bit more info? You want to keep the RadDataForm in edit mode, so that you can immediately commit any changes, am I right? Please, try setting AutoEdit to "true" and inform us whether this behavior fits your needs.

Best wishes,
Ivan Ivanov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
Tags
DataForm
Asked by
Nelson
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Nelson
Top achievements
Rank 1
Share this question
or