Erro com canceledit ao inserir novo item

4 posts, 0 answers
  1. KLEBER
    KLEBER avatar
    6 posts
    Member since:
    Apr 2011

    Posted 17 Jan 2012 Link to this post

    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.
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 18 Jan 2012 Link to this post

    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 >>

  3. DevCraft banner
  4. KLEBER
    KLEBER avatar
    6 posts
    Member since:
    Apr 2011

    Posted 18 Jan 2012 Link to this post

    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.
  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 19 Jan 2012 Link to this post

    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 >>

Back to Top