Very weird issue with multi-select in grid

I’m encountering the weirdest issue and I’m at a loss of how to debug it…

I’m using the same code in two grids and in one grid SelectionMode.MULTI works as expected but in the other grid right after I select it (I can see the selection appear) within the blink of an eye the row is unselected. If I bring it back to SelectionMode.SINGLE then everything works. As well this weird behavior is across multiple browsers. It’s the exact same code and everything looks correct.

What’s even weirder is that I can do select all (clicking on the box in the column header) and all items are selected. I can then unselect the rows I don’t want. However once I unselect a row I can no longer re-select it unless I do select all, otherwise I experience the same behavior in that it’s immediately unselected within the blink of an eye.

Therefore I would love some help as to where to even start debugging this? I tried to even add hooks into the SelectionListener and it’s firing correctly, so it’s not as if it’s being re-selected (unselected). I’m at a complete lost as to where or how to debug this weird behavior. I also looked for anything like grid.setItems() and other than the initialization there are no calls to setItems().

The code is identical for the two grids, in fact I went so far as to copy and paste it. If there’s something different it can only because I missed something in the copy and paste while testing.

Anyways any help in trying to debug this issue would be extremely appreciated. I’m at a loss of what it could possibly be, as well as what to debug. I’ve tried to hook in all kinds of listeners, etc. and I’m out of places to try to even hook code or the debugger…

Regards,
Steph

After many hours I figured out how to resolve it but I have no idea why the solution works…

Basically I had a Grid of Invoices and one of Receipts. Both Invoices and Receipts extended from the same parent class. Invoices always worked but Receipt (and any other that extended from the same shared parent) failed. I then just extended Receipt from Invoice, which although incorrect, resolve the issue. I have no idea why or how this could be related but that was the only way I could fix the issue. Again I’m completely baffled at how this could fix the multi selection issue on the grid…

Any possible explanations would be appreciated…

Do you have a selection listener that is changing the grid items triggering a data refresh? That could clear the selection.

Does your Receipt class implement equals/hashcode? I guess Grid needs this to identify the (selected) items.

The the code is exactly:

public class Invoice extends CommonCode
{
}

And if I have:

public class Receipt extends CommonCode
{
}

I get that weird behavior. But I change it to:

public class Receipt extends Invoice
{
}

Then it works as expected. This 100% replicates the issue consistently. In other words I’ve removed everything else possible, even the code to generate the grid, etc. This is why I’m so confused!!!