Issue with image cells popping up where they shouldn't

Posted by: kp on 18 June 2020, 8:59 pm EST

  • Posted 18 June 2020, 8:59 pm EST

    I have a gridview that correctly sets up the data and images where they should be, but after scrolling for a bit it starts going crazy with where is places images (see attached images).

    I think it is related to the reusing of cells, where is the best place to fix them so image cells aren't used the wrong places?

    Alternatively if you think it is something else I'd also like to know what it could be.
  • Replied 18 June 2020, 11:21 pm EST

    For added info, my createCellContent method consists of:
    If(isImage = true){
    return imageview
    }
    else{
    return base.CreateCellContent(cellType, range, cellContentType);
    }

    and my bindcellcontent method has a check whether the content is an imageview
  • Replied 25 June 2020, 1:48 am EST

    Hi KP

    The issue can be replicated at my end, I have escalated it to the concerned team with internal tracking id : 442572, and will update you once we get any information from them.

    Please let me know if you need any other help.

    Thanks
  • Replied 25 June 2020, 5:42 pm EST

    I managed to make it remove the images by overriding the Unbindcellcontent method, though that just made images disappear completely, since the grid doesn't enter the createcellcontent class again(where I add images).
  • Replied 29 June 2020, 1:25 am EST

    Hi KP

    We are glad to hear that you are able to manage the unwanted popping up of Image cell.

    Please let me know if you need any other help.

    Thanks
  • Replied 29 June 2020, 3:53 am EST

    Hi KP,

    You're right this is because of the recycling. In order to recycle cells correctly you must override GetCellContentType method, and return any key (It could be typeof(Image)), otherwise the grid will "think" the cells contain text, and the Images will be recycled together with the labels, causing unexpected behavior.

    The recycling needs overriding the three methods GetCellContentType, CreateCellContent and BindCellContent.

    The first tells the grid what kind of content there is in the cell, the second creates the UI element, and the third binds the UI with the data item. When the key returned in GetCellContentType corresponds to a "bucket" containing recycled cells, the CreateCellContent is not called and the recycled cells is used. Next, the BindCellContent is executed (to update the image source in your case). The UnbindCellContent is not mandatory but it is useful to detach to events that were attached in the BindCellContent.

    Hope it helps,
    Alvaro.
  • Replied 29 June 2020, 6:58 pm EST

    Alvaror, thank you this seems to help immensely, I still need to do some texting, but just override the getcellcontenttype method seems to have done wonders.
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels