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

Erro com canceledit ao inserir novo item

3 Answers 32 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
KLEBER
Top achievements
Rank 1
KLEBER asked on 18 Jan 2012, 12:28 AM
Hi.
I am implementing a DataForm, and insert a new item, when you cancel displays the following error.
"CancelEdit is not allowed during a transaction begun by addnew"

This is my code.

<telerik:RadWindow x:Class="Quest.TabelasBasicas.ConsultarPilar"
                   xmlns:riacontrols="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.DomainServices"   
    xmlns:rialocal="clr-namespace:Quest.Web"
        Header="ConsultarPilar" Height="500" Width="600">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="200"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.Resources>
            <DataTemplate x:Key="TemplateDataFormReadOnly">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="250"></ColumnDefinition>
                        <ColumnDefinition Width="100"></ColumnDefinition>
                        <ColumnDefinition Width="100"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <telerik:DataFormDataField Label="Pilar" DataMemberBinding="{Binding descricaoPilar, Mode=OneWay}" Grid.Column="0" LabelPosition="Above" Description="Nome do Pilar">
                    </telerik:DataFormDataField>
                    <telerik:DataFormDataField Label="Peso" DataMemberBinding="{Binding peso, Mode=OneWay}" Width="100" Grid.Column="1" LabelPosition="Above" Description="Peso do Pilar">
                    </telerik:DataFormDataField>
                    <telerik:DataFormDataField  Label="Pontos" DataMemberBinding="{Binding pontos,Mode=TwoWay}" Width="100" Grid.Column="2" LabelPosition="Above" Description="Pontos do Pilar">
                    </telerik:DataFormDataField>
                </Grid>
            </DataTemplate>
            <DataTemplate x:Key="TemplateDataForm">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="250"></ColumnDefinition>
                        <ColumnDefinition Width="100"></ColumnDefinition>
                        <ColumnDefinition Width="100"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <telerik:DataFormDataField Label="Pilar" Grid.Column="0" LabelPosition="Above" Description="Nome do Pilar">
                        <telerik:RadMaskedTextBox MaskType="None" Value="{Binding descricaoPilar, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" ></telerik:RadMaskedTextBox>
                    </telerik:DataFormDataField>
                    <telerik:DataFormDataField Label="Peso" Width="100" Grid.Column="1" LabelPosition="Above" Description="Peso do Pilar">
                        <telerik:RadMaskedTextBox MaskType="Numeric" Culture="pt-BR" Grid.Row="1" TabIndex="7" Grid.Column="1" Margin="2"  VerticalAlignment="Center" Height="22" MaskedText="{Binding peso, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" Mask="d"  />
                    </telerik:DataFormDataField>
                    <telerik:DataFormDataField Label="Pontos" Width="100" Grid.Column="2" LabelPosition="Above" Description="Pontos do Pilar">
                        <telerik:RadMaskedTextBox MaskType="Numeric" Culture="pt-BR" Grid.Row="1" TabIndex="7" Grid.Column="1" Margin="2"  VerticalAlignment="Center" Height="22" MaskedText="{Binding pontos, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true}" Mask="d"  />
                    </telerik:DataFormDataField>
                </Grid>
            </DataTemplate>
        </Grid.Resources>      
        <riacontrols:DomainDataSource LoadedData="TelaDS_LoadedData"  x:Name="TelaDS" AutoLoad="True" QueryName="GetPilar">
            <riacontrols:DomainDataSource.DomainContext>
                <rialocal:QuestDomainContext />
            </riacontrols:DomainDataSource.DomainContext>         
        </riacontrols:DomainDataSource>
        <telerik:RadDataForm x:Name="dtForm" EditEnded="dtForm_EditEnded" EditEnding="dtForm_EditEnding"  Margin="2" ItemsSource="{Binding Data, ElementName=TelaDS}" LabelPosition="Above" AutoGenerateFields="False" AutoEdit="False" AutoCommit="False" CancelButtonContent="Cancelar" CommitButtonContent="Salvar"
                             ReadOnlyTemplate="{StaticResource TemplateDataFormReadOnly}"                            
                             NewItemTemplate="{StaticResource TemplateDataForm}"
                             >
        </telerik:RadDataForm>
        <telerik:RadGridView Grid.Row="1" Margin="2" ItemsSource="{Binding Data, ElementName=TelaDS}" >
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn Header="Pilar" DataMemberBinding="{Binding descricaoPilar, Mode=OneWay}" />
                <telerik:GridViewDataColumn Header="Peso" DataMemberBinding="{Binding Peso, Mode=OneWay}" />
                <telerik:GridViewDataColumn Header="Pontos" DataMemberBinding="{Binding Pontos, Mode=OneWay}" />
                <telerik:GridViewDataColumn Header="Status" DataMemberBinding="{Binding status, Mode=OneWay}" />               
            </telerik:RadGridView.Columns>
        </telerik:RadGridView>       
    </Grid>
</telerik:RadWindow>

Please help me.

Best regards.

3 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 18 Jan 2012, 07:46 AM
Hi,

 May you please let me know how do you cancel the insert? Do you cancel it when the "dtForm_EditEnded" event is raised?

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
KLEBER
Top achievements
Rank 1
answered on 18 Jan 2012, 06:59 PM
Hi.
I do not call the event manually, i just click on insert button from dataform without add information, then when click on cancel button, get error.

Regards.
0
Dimitrina
Telerik team
answered on 19 Jan 2012, 05:16 PM
Hi,

 I have tried to get such an error on cancelling the insert, but I was not able to. How do you submit the changes for the DomainDataSource? Do you get the same behaviour if you use the RadDomainDataSource?

Regards,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
DataForm
Asked by
KLEBER
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
KLEBER
Top achievements
Rank 1
Share this question
or