현재 GXT 3을 사용하여 트리에 요소를 표시하고 있습니다. 이러한 요소는 데이터베이스에서 검색되고 트리에서 ID로 식별됩니다 (즉, ID는 내 상점의 ModelKeyProvider 임). 는 또한 가능 사용자가 다음과 같은 코드 트리에서 로컬 객체를 생성 할 수있었습니다 : 당신이 볼 수 있듯이GXT 3는 treeStore의 요소를 동적으로 업데이트합니다.
private Tree<EntityDAO, String> tree;
private TreeStore<EntityDAO> store;
int count = 1;
// instanciation and irrelevant stuff
...
EntityDAO sel = tree.getSelectionModel().getSelectedItem();
EntityDAO child = new EntityDAO();
child.setId((long) count);
store.add(store.getParent(sel), child);
count++;
tree.setExpanded(sel, true);
tree.getSelectionModel().select(child, false);
, 난 내 로컬 객체에 대한 임시 ID를 (계산)을 설정합니다. 개체를 데이터베이스에 저장할 때 문제가 발생합니다. 영원한 ID는 내 EntityDAO로 설정되지만이 ID를 로컬 개체에 설정하여 데이터베이스와 동기화하려고하면 작동하지 않습니다. 내가 직접
child.setId(result);
tree.update(child);
내가 적절한 ID로 내 객체의 복사본을 추가 한 다음 트리
EntityDAO newPR = child;
newPR.setId(result);
store.add(store.getParent(child), newPR);
store.remove(child);
에서 내 개체를 제거하려고 한 자식 ID를 수정하려고했습니다 그러나 디스플레이는 절대로 업데이트되지 않습니다. 어떤 단서?
필자는 EntityDAO 클래스의 복제 방법을 구현했는데, 이는 기본적으로 권고 한 것입니다. 감사. –