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

Current Row change on adding new Row

8 Answers 586 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Huzaifa
Top achievements
Rank 1
Huzaifa asked on 23 Jul 2010, 04:06 PM
When new Row added in the Grid, it change my current selected row to the newly added row. I have bind Grid to the BindingList. Please advice how to overcome this issue. Because I don't want to change current selection on addition of new row.

Regards,
Huzaifa

8 Answers, 1 is accepted

Sort by
0
Emanuel Varga
Top achievements
Rank 1
answered on 23 Jul 2010, 05:01 PM
Hello Huzaifa,

Sadly i've been trying to resolve this and some similar issues for a time now with telerik support and until now i don't have a viable solution.

You could try manually remembering the last selected row, something like this:

Snippet
        private void addRowButton_Click(object sender, EventArgs e)
        {
            var selectedRow = radGridView1.CurrentRow;
            objectCollection.Insert(0, new CustomObj(n)
            {
                Name = "Name" + n
            });
            radGridView1.CurrentRow = selectedRow;
            n++;
        }

I know it's a pretty ugly workaround but it should work as a last resort...
I will keep you posted as soon as i know something.

Emanuel, Varga
0
Huzaifa
Top achievements
Rank 1
answered on 23 Jul 2010, 07:33 PM
Can I get any event like Before Row adding and after row added? I update Binding List on backend where i don;t have access of Grid. Otherwise I have to unbind the Grid. Please advice..!!

Regards,
Huzaifa
0
Julian Benkov
Telerik team
answered on 28 Jul 2010, 03:35 PM
Hello Huzaifa,

In the new version of RadGridView control you can use two new events for this scenario - UserAddingRow / UserAddedRow.

Regards,
Julian Benkov
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
0
Emanuel Varga
Top achievements
Rank 1
answered on 28 Jul 2010, 03:39 PM
Hello,

The UserAddingRow event is not firing, and without that event there is no point...

Sorry i have no other workarounds, maybe you can implement your own ListChanging event that will get called before an actual changed occur and after that use the UserAddedRow event or you could set the RaiseListChangedEvents = true if you are using a binding list and register for the list changed event in the form for the latter action.

Hoping for a better solution

Sorry for the late reply,
Emanuel Varga
0
Alexander
Telerik team
answered on 03 Aug 2010, 01:21 PM
Hello,

The event UserAddingRow is fired when the user populates the new row of RadGridView and adds it to the control.

When a new row is added programmatically, the CollectionChanged event of the Rows collection is fired:
this.radGridView1.Rows.CollectionChanged

The default behavior of the RadGridView control is to set as current row the current element of its BindingSource. The above event could be used to implement custom behavior.

Best regards,
Alexander
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
0
Emanuel Varga
Top achievements
Rank 1
answered on 03 Aug 2010, 01:24 PM
Hello Alexander,

That's exactly right , but like i said before that fires only AFTER the collection has been changed, if you don't have an event that fires before the actual change you cannot remember the row you're currently on and from what I'm understanding this will be from now the standard behavior for the grid view...

Best Regards,
Emanuel Varga
0
Alexander
Telerik team
answered on 06 Aug 2010, 03:39 PM
Hello Emanuel,

The SP1 version of RadGridView (to be released next week), has a new feature on tracking newly added rows in the DataSource of the control. The SelectLastAddedRow property is also introduced in the RadGridView template. It will allows you to choose if the current row will change to the newly added row or will remain the same.

Thank you for your feedback regarding this scenario. It helped us to improve the behavior of the control.

Best regards,
Alexander
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
0
Huzaifa
Top achievements
Rank 1
answered on 07 Aug 2010, 07:46 AM
Thanks for you support. Hope new release will resolve the issue.

Regards,
Huzaifa
Tags
GridView
Asked by
Huzaifa
Top achievements
Rank 1
Answers by
Emanuel Varga
Top achievements
Rank 1
Huzaifa
Top achievements
Rank 1
Julian Benkov
Telerik team
Alexander
Telerik team
Share this question
or