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

suppres row/cell receycling (Virtual mode)

3 Answers 105 Views
GridView
This is a migrated thread and some comments may be shown as answers.
OLIVER
Top achievements
Rank 1
OLIVER asked on 27 Jun 2013, 01:57 PM
Hello supportteam,

according to the article "Create pop-up user control for row editing" we implemented a UserControl acting as a roweditor, which is hosted in a RadMenuHostItem by a Custom cell - all works fine. As proposed in the example the editor control is instantiated in a RadGridView.CreateCell event handler.

Now the problem: When I remove a row from the grid and add a new one the CreatedCell handler will not be called, I guess because there is no need hence the grid receycles the removed row to display the new one (Virtual mode).

Is there a way to suppres "receyling" of gridrows, so CreatedCell is fired all the time I call RadGridView.Rows.AddRow? Performance is not a not problem as the the number of rows will be just a few.

Best regards &
Thanks for any advice,
Oliver

3 Answers, 1 is accepted

Sort by
0
Paul
Telerik team
answered on 02 Jul 2013, 12:44 PM
Hi Oliver,

Thank you for writing.

Yes there is a way to suppress reusing the visual elements, but it is not advisable to do so. If you want the CreateCell event to be called every time when you create new row, you can subscribe to the appropriate event (UserDeletedRow for example) and clear the cash of the CellElementProvider collection. 
Here is a code snippet:
void radGridView1_UserDeletedRow(object sender, GridViewRowEventArgs e)
{
    this.radGridView1.TableElement.CellElementProvider.ClearCache();
}

This however would greatly slow down the grid and might bring unwanted behavior. If you share more about your requirement, I am sure we can think of more appropriate solution.

Look forward to hearing if we can be of further assistance.

Regards,
Paul
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
OLIVER
Top achievements
Rank 1
answered on 02 Jul 2013, 01:08 PM

 

Hey Paul,

thanks for your reply, your proposed code works fine.

As mentioned in my case the table encompasses just a few records, so perfomance is no problem in this case.

The initial problem was that we created a custom row editor control as proposed here:
http://www.telerik.com/support/kb/winforms/gridview/create-pop-up-user-control-for-row-editing.aspx
In our implementation the row editor is instatiated per cell in CreatedCell Handler (which is not called if cell is recycled).
If rows are removed from the grid and new ones are created cells are recycled including their editor instances. So if a user opens up a recycled editor he will see the data of a former removed row. As a workaround I meanhile reset the editor to an initial state which also works fine.

Thanks for support &
Best regards
Oliver

0
Stefan
Telerik team
answered on 05 Jul 2013, 05:05 AM
Hello Oliver,

Thank you for sharing this information with us. I am glad you have sorted this out.

Your approach of resetting the editor seems to be valid. To to have an alternative, I would mention that you can use the EditorRequired event where you can always create a new instance of the editor needed, and this way you will prevent re-usage of editors.

I hope that you find this information useful.

Regards,
Stefan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
OLIVER
Top achievements
Rank 1
Answers by
Paul
Telerik team
OLIVER
Top achievements
Rank 1
Stefan
Telerik team
Share this question
or