Sorry, could you clarify your problem a bit? What exactly is null in your example situation? You don’t have any rows selected, or are trying to move the topmost row up, or something else entirely? You’d need to add special handling for those situations.
sorry for my bad English , what I want is my reorder grid rows , either up or down , to reorder up eg change the ranks of site but the row is blank rises above
I guess your row properties aren’t initialised automatically, so if you remove the item, and add it back to a different spot, you’ll need to reinitialise the contents or your columns will be blank. You might want to consider just reordering the container instead of removing the item temporarily, but it depends on your container how that would happen in practice and whether it allows it at all, can’t remember off the top of my head if I’ve ever tried it myself.
Also note that you can’t add components to a Grid, you’ll need a ButtonRenderer instead of a Button if this is something you want on every row.
My button is outside the grid , the operation would select a row in the grid , then capture the value of that row with the button and finally reorder row
Well, assuming you use Grid’s default IndexedContainer, consider trying out HierarchicalContainer instead. It has method
moveAfterSibling(Object itemId, Object siblingId)
that should come in handy. You might need to change how you initialise your Grid a bit – can’t use addColumn or addColumnProperty shortcuts if you don’t use the default container – but should be doable. I’m afraid I don’t have time to try it out myself at the moment, but I hope it will help you forward.
You could still use the container’s own methods for that, it’s only the Grid helper methods that break. I suspect you would need much more work to get it working with the default container than by converting to a different container that has item moving as a built-in property.
I had an idea , as the container indexed or beanitemcontainer can take your ArrayList inside, reordered the arraylist , I was debugging and did it well , gave me an error when deleting my grid and add the container , but it has to be easy to solve think I
Perfectly was solved first reorder arraylist , then delete all the items in the grid , I loop arraylist and will dynamically inserting values and finally, keep selection after moving a row, thanks for everything, I leave this post in case anyone most he can serve. a greeting