Reorder your model and call refresh passing the parent domain object.
Tom
On 25.07.13 06:08, cheng shouwu wrote:
> Hi Dears:
>
> I am using GridTreeViewer,and now When I select a row in it and want to
> move it to above the previous row(the same level),what method I can do?
cheng shouwu Messages: 12 Registered: September 2012
Junior Member
yes,I has done with this way,but it can not work correctly.after saved and reopen it,it can show correctly
//itemEntity is one which want to be moved up
//finde the parent
ProjectitemEntity parent = itemEntity.getParent();
//sub items
List<ProjectitemEntity> subItems = parent.getSubItems();
int i = subItems.indexOf(itemEntity);
//above item
ProjectitemEntity aboveItem = subItems.get(i-1);
//reorder
itemEntity.setOrdNo(i-1);
aboveItem.setOrdNo(i);
//refresh
itemTreeGrid.refresh(parent);
Have you set a ViewerComparator, who tells the viewer to sort your
subitems according to the ordNo?
Tom
On 25.07.13 10:35, cheng shouwu wrote:
> yes,I has done with this way,but it can not work correctly.after saved
> and reopen it,it can show correctly
>
> //itemEntity is one which want to be moved up
> //finde the parent
> ProjectitemEntity parent = itemEntity.getParent();
> //sub items
> List<ProjectitemEntity> subItems = parent.getSubItems();
> int i = subItems.indexOf(itemEntity);
> //above item
> ProjectitemEntity aboveItem = subItems.get(i-1);
> //reorder
> itemEntity.setOrdNo(i-1);
> aboveItem.setOrdNo(i);
> //refresh
> itemTreeGrid.refresh(parent);