On Delete Item Source is not refreshing

Apr 16, 2014 at 4:14 AM
Hi ,

While I am deleting the row from View model Grid is not Refreshing.

Thanks & Regards
Lucky Ahuja
Coordinator
Apr 16, 2014 at 4:25 AM

Try grid.items.Refresh

I guess u didn't bind it properly.

Apr 16, 2014 at 10:21 AM
Edited Apr 16, 2014 at 10:25 AM
Hi,

I am using the Extended DLL in another Project . And the project in which i am using the Extended Dll is build using MVVM. This is my Code
        <ExtendedGridControl:ExtendedDataGrid x:Name="grid" ItemsSource="{Binding Path=Students, Mode=TwoWay}" RowHeaderWidth="17"  AutoGenerateColumns="False" HideColumnChooser="False" GroupByControlVisibility="Visible" CanUserDeleteRows="True"
            IsSynchronizedWithCurrentItem="True" SelectionMode="Extended" SelectionUnit="FullRow" CanUserAddRows="False" OnlyTwoWaySorting="True" SearchAutoFilterVisibility="Visible" AutoFilterFontSize="12" AlternatingRowBackground="Azure" Width="600">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="RowHeaderClick" >
                    <i:InvokeCommandAction Command="{Binding SingleClicktMaster}"/>
                </i:EventTrigger>
                <i:EventTrigger EventName="RowHeaderMouseDoubleClick" >
                    <i:InvokeCommandAction Command="{Binding DoubleClicktMaster}"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
            <ExtendedGridControl:ExtendedDataGrid.Columns>
                <ExtendedColumn:ExtendedDataGridTextColumn Header="First Name" AllowAutoFilter="True"
                    Binding="{Binding Path=FirstName}" Width="100" />
                <ExtendedColumn:ExtendedDataGridTextColumn Header="Middle Name" AllowAutoFilter="True"
                    Binding="{Binding Path=MiddleName}" Width="100" />
                <ExtendedColumn:ExtendedDataGridTextColumn Header="Last Name"
                    Binding="{Binding Path=LastName}" AllowAutoFilter="True" Width="100"/>
                <ExtendedColumn:ExtendedDataGridTextColumn Header="Age"
                    Binding="{Binding Path=Age}" AllowAutoFilter="True" Width="100">
                </ExtendedColumn:ExtendedDataGridTextColumn>
                <ExtendedColumn:ExtendedDataGridTextBoxColumn Width="*">
                       <ExtendedColumn:ExtendedDataGridTextBoxColumn.CellTemplate>
                          <DataTemplate>
                            <Button Name="btnDelete"  IsEnabled="True" Content="Delete"  Command="{Binding Path=DataContext.simpleCommand,RelativeSource={RelativeSource AncestorType={x:Type ExtendedGridControl:ExtendedDataGrid}}}" CommandParameter="{Binding}" />
                          </DataTemplate>
                       </ExtendedColumn:ExtendedDataGridTextBoxColumn.CellTemplate>
                </ExtendedColumn:ExtendedDataGridTextBoxColumn>
            </ExtendedGridControl:ExtendedDataGrid.Columns>
            <ExtendedGridControl:ExtendedDataGrid.FooterDataTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="RowsCount:" FontWeight="Bold"/>
                        <TextBlock Margin="3,0,0,0" Foreground="DarkGreen"  Text="{Binding Items.Count, ElementName=grid}"/>
                    </StackPanel>

                </DataTemplate>
            </ExtendedGridControl:ExtendedDataGrid.FooterDataTemplate>
        </ExtendedGridControl:ExtendedDataGrid>
and in the View Model class this is the collection which I am Binding
public ObservableCollection<Student> Students
    {
        get { return _obserstudents; }
        set
        {

            _obserstudents = value;
            NotifyPropertyChanged("Students");
        }

}

this is what I am doing when I click the delete button in the grid

Adding this in Constructor

simpleCommand = new RelayCommand(new Action<object>(DoSimpleCommand));

this Command is added when delete button Clicked on UI

public ICommand simpleCommand
    {
        get
        {
            return _simpleCommand;
        }
        set
        {
            _simpleCommand = value;
        }
    }
private void DoSimpleCommand(object obj)
    {
        try
        {
            Students.RemoveAt(0);  

        }
        catch (Exception ex)
        {
            //MessageBox.Show("Error occurred while saving the case. Please contact Manager/Supervisor.");
        }

    }


Apr 17, 2014 at 2:28 PM
I got it .

It was the custom Pager Control which was creating problem . Rest the Grid is running fine