2014-01-17 2 views
0

저는 CellTable을 사용하는 GWT 앱을 사용하여 명칭과 수량에 대해 2 개의 열을 표시하고 있습니다. 수량 값을 편집 할 수있는 경우에는 금액 값을 편집 할 수 없습니다.CellTable 셀의 값을 얻는 방법

나는 사용자가 예를 들어 선택하면, 교단에 대한 5 수량 20, 총 텍스트 상자 5 * 20 = 100

내 질문은 자동으로 채워야입니다 직시 무엇을, 어떻게 내가 할 수있는 곱셈을 할 수 있도록 셀 값을 검색하십시오.

추 신 : 값은 모두 데이터베이스 테이블에 저장됩니다.

답변

1

셀 테이블에 selectionModel을 연결하여 현재 선택된 행을 가져온 다음 현재 선택한 객체를 가져 와서 해당 값을 가져올 수 있습니다. 다음 진술에 대해 완전히 확신하지는 않지만 FieldUpdater도 사용할 수 있습니다. GWT에서의 문서 here을 참조하십시오

샘플 :

선택 모델 :

SingleSelectionModel<Contact> selectionModel = new SingleSelectionModel<Contact>(); 
    table.setSelectionModel(selectionModel); 
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { 
     public void onSelectionChange(SelectionChangeEvent event) { 
     Contact selected = selectionModel.getSelectedObject(); 
     if (selected != null) { 
      Window.alert("You selected: " + selected.name); 
     } 
     } 
    }); 

FieldUpdater :

// Add a field updater to be notified when the user enters a new name. 
    nameColumn.setFieldUpdater(new FieldUpdater<Contact, String>() { 
     @Override 
     public void update(int index, Contact object, String value) { 
     // Inform the user of the change. 
     Window.alert("You changed the name of " + object.name + " to " + value); 

     // Push the changes into the Contact. At this point, you could send an 
     // asynchronous request to the server to update the database. 
     object.name = value; 

     // Redraw the table with the new data. 
     table.redraw(); 
     } 
    }); 
+0

O.K가 나중에 그것을 밖으로 시도하고 feedback.Thanks을 줄 것이다. – CodeMarshal

+0

감사합니다. Onker, 매우 잘 작동했습니다. – CodeMarshal

+0

@CodeMarshal은 대리점을 얻지 못하지만이를 수락 및/또는 투표로 표시하면 더 이상 공개 질문으로 나타나지 않고 동일한 의심을 가진 다른 사람들이 도움이 될 것입니다. – Onkar

관련 문제