suppres row/cell receycling (Virtual mode)

4 posts, 0 answers
  1. OLIVER
    OLIVER avatar
    4 posts
    Member since:
    Aug 2012

    Posted 27 Jun 2013 Link to this post

    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
  2. Paul
    Admin
    Paul avatar
    60 posts

    Posted 02 Jul 2013 Link to this post

    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 >>
  3. OLIVER
    OLIVER avatar
    4 posts
    Member since:
    Aug 2012

    Posted 02 Jul 2013 Link to this post

     

    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

  4. Stefan
    Admin
    Stefan avatar
    2911 posts

    Posted 05 Jul 2013 Link to this post

    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 >>
Back to Top