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

Error on pressing multiple Delete button to delete row on radgridview

2 Answers 48 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tai
Top achievements
Rank 1
Tai asked on 02 Sep 2010, 09:42 PM
Hi


I am using RIA service and domainDatasource control in order to supply the data to the radgridview

My current problem is that:
-pressing delete one time for a row is ok. However, if i press multiple delete(right now is 3 times continuously), the first two rows will be deleted safely but it will crash at the 3rd row because it says that other delete is in process(maybe it is waiting for the process submiting the change back to the database)
Note: i check on your demo and notice that every time i delete a row. The grid won't automatically highlight the next row. It is good because every time i need to delete a row , i have to select it first . THat might fix my problem. However, I don't know how to defocus like that

+Can you also check for me whether the method i am using for setting default value of a cell in a row is correct or not?
the problem is that if i switch the order of these two then it won't work. Not sure why?
(financialAccountDomainDataSource.DomainContext asFinancialAccountContext).FinancialAccounts.Add(financialAccount);
   e.NewObject = financialAccount;



this is my code:

<riaControls:DomainDataSource AutoLoad="True" d:DesignData="{d:DesignInstance my:FinancialAccount, CreateList=true}" Height="0" LoadedData="financialAccountDomainDataSource_LoadedData" Name="financialAccountDomainDataSource" QueryName="GetFinancialAccountsQuery" Width="0" Margin="0,0,616,416">
           <riaControls:DomainDataSource.DomainContext>
               <my1:FinancialAccountContext x:Name="financialAccountContext"/>
           </riaControls:DomainDataSource.DomainContext>
       </riaControls:DomainDataSource>
       <telerik:RadGridView   ShowGroupPanel="False" 
                               DataLoadMode="Asynchronous" AutoGenerateColumns="False" ItemsSource="{Binding ElementName=financialAccountDomainDataSource, Path=Data}" Name="financialAccountRadGridView"
                              AddingNewDataItem="financialAccountRadGridView_AddingNewDataItem"
                              RowEditEnded="financialAccountRadGridView_RowEditEnded"
                                  
                               
                             Deleted="financialAccountRadGridView_Deleted" EnableRowVirtualization="True">
           <telerik:RadGridView.Columns >
               <telerik:GridViewDataColumn DataMemberBinding="{Binding AccountNumber, Mode=TwoWay}" Header="Account Number"/>
               <telerik:GridViewDataColumn DataMemberBinding="{Binding AccountDescription, Mode=TwoWay}" Header="Account Name"/>
                
               <telerik:GridViewComboBoxColumn ItemsSource="{Binding ListFinancialTypes, Source={StaticResource financialAccountTypes}}"
                                               DataMemberBinding="{Binding FinancialAccountTypeId, Mode=TwoWay}"
                                               Header="Account Type"
                                               DisplayMemberPath="AccountTypeName"
                                               SelectedValueMemberPath="FinancialAccountTypeId"/>
               <telerik:GridViewComboBoxColumn ItemsSource="{Binding ListofActiveStatus, Source={StaticResource activeStatusList}}"
                                               DataMemberBinding="{Binding Active, Mode=TwoWay}"
                                               Header="Active"
                                               UniqueName="Active"
                                                  
                                               DisplayMemberPath="ActiveDes"
                                               SelectedValueMemberPath="ActiveInt"/>
               <telerik:GridViewDataColumn DataMemberBinding="{Binding ConsolidationAccount, Mode=TwoWay}" Header="Consolidation"/>
 
           </telerik:RadGridView.Columns>
       </telerik:RadGridView>


Code behind

//TODO: setting default value for Active property of financial Account before inserting
 private void financialAccountRadGridView_AddingNewDataItem(object sender, Telerik.Windows.Controls.GridView.GridViewAddingNewEventArgs e)
{
    var financialAccount = new FinancialAccount();
    financialAccount.Active = 1;
   (financialAccountDomainDataSource.DomainContext as FinancialAccountContext).FinancialAccounts.Add(financialAccount);
   e.NewObject = financialAccount;
}
 
private void financialAccountRadGridView_RowEditEnded(object sender, Telerik.Windows.Controls.GridViewRowEditEndedEventArgs e)
{
    financialAccountDomainDataSource.DomainContext.SubmitChanges();
}
 
private void financialAccountRadGridView_Deleted(object sender, Telerik.Windows.Controls.GridViewDeletedEventArgs e)
{
    financialAccountDomainDataSource.DomainContext.SubmitChanges();
}                








2 Answers, 1 is accepted

Sort by
0
Tai
Top achievements
Rank 1
answered on 06 Sep 2010, 08:03 PM
plz help me on this one. It has problem about delete when i have a GridViewComboBox inside.
0
Accepted
Nedyalko Nikolov
Telerik team
answered on 07 Sep 2010, 12:37 PM
Hello Tai,

I cannot simulate any issue when Delete button is pressed continuously indeed there is a lag between delete operations, so probably the reason could be some pending delete operation. You can achieve behavior like in our example with setting RadGridView.IsSynchronizedWithCurrentItem="False", this will force user to navigate (via keyboard or mouse) to the next item for delete and then to press Delete key.

About the problem with new items, I think that you have to add this new item to the collection on RowEditEnded event (you can get EditOperationType property from the event arguments), because if edit is canceled you will end up with an item in RadGridView collection at least.

I hope this helps.

Greetings,
Nedyalko Nikolov
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
Tags
GridView
Asked by
Tai
Top achievements
Rank 1
Answers by
Tai
Top achievements
Rank 1
Nedyalko Nikolov
Telerik team
Share this question
or