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

Don't Add New Row, on validation fails

1 Answer 59 Views
GridView
This is a migrated thread and some comments may be shown as answers.
crazy05
Top achievements
Rank 1
crazy05 asked on 20 May 2015, 07:09 PM

I am using Interaction trigger on RowEditEnded. If the user enter invalid value, I want to remove that row from the Grid. How can I do this ?

ItemsSource="{Binding ItemSource,Mode=TwoWay }"

 <i:Interaction.Triggers>
                    <i:EventTrigger EventName="RowEditEnded">
                        <cmd:EventToCommand Command="{Binding EditingCommand}" />
                    </i:EventTrigger>
                </i:Interaction.Triggers>

 

 if (this.ItemSource.Count > 0)
            {
                var newItem = this.ItemSource.FirstOrDefault(d => d.ItemOrder == null);

                if (newItem != null)
                {
                    if (newItem.Id > 0)
                    {
                       newItem .ItemOrder = this.ItemSource.Count;
                    }
                    else
                    {
                        this.ItemSource.Remove(newItem );
                    }   
                }
            }

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 22 May 2015, 12:35 PM
Hi Ram,

You have to work with the source collection that the grid is bound to. If you have ObservableCollection<Club> Clubs for example in your ViewModel that is the source of the grid, you can just remove the item from it and the grid will reflect the changes. 

Regards,
Maya
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
crazy05
Top achievements
Rank 1
Answers by
Maya
Telerik team
Share this question
or