Issue with image cells popping up where they shouldn't

Posted by: kp on 19 June 2020, 5:59 am EST

  • Posted 19 June 2020, 5:59 am EST - Updated 30 September 2022, 9:22 am 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.

  • Posted 19 June 2020, 8:21 am 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

  • Posted 25 June 2020, 10: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

  • Posted 26 June 2020, 2:42 am 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).

  • Posted 29 June 2020, 10: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

  • Posted 29 June 2020, 12:53 pm 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.

  • Posted 30 June 2020, 3:58 am 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