2012-03-01 3 views
7

RPC 호출에서 서버로 데이터를로드 할 때 GIF DataGrid의 기능을 사용하여 애니메이션 GIF를 표시하려고합니다.GWT DataGrid setLoadingIndicator는 아무런 효과가 없습니다.

나는 어떤 자원도 찾지 못했습니다. 이것에 대한 지원은 정말 가난합니다.

내가 사용하여 내 데이터 그리드를 inizialize :

myDataGrid.setLoadingIndicator(new Image(/*my ImageResource object*/); 

프로그램의 흐름 동안

내가 사용 : 난 그냥 즉, '로드'상태에서 데이터 그리드를 넣을

myDataGrid.fireEvent(new LoadingStateChangeEvent(LoadingState.LOADING)); 

RPC 호출을하기 전에 다음을 수행하십시오.

myDataGrid.fireEvent(new LoadingStateChangeEvent(LoadingState.LOADED)); 

그리드가 데이터로 채워진 직후.

이것은 작동하지 않습니다. DataGrid에 변경 사항이 표시되지 않고 애니메이션 GIF가 표시되지 않습니다. 프로세스 중에는 변경되지 않습니다. 내가 뭘 잘못하고 있니?

도와주세요.

+0

예, RPC (원격 프로 시저 호출)를 의미했습니다. 예, GWT가 서버와 통신하는 데 사용하는 표준 방법. 그것에 집중하지 마십시오. 질문은 DataGrid의로드 상태에 관한 것입니다. DataGrid의 '로드 중'상태를 설정하여 setLoadingIndicator() 함수를 사용하여 이전에 설정 한로드 표시기를 보여줄 수 있습니다. 그런 다음 어떻게하면 DataGrid의 '로드 됨'상태를 다시 설정할 수 있습니까? 로드 된 행이 표시됩니까? 이것이 진정한 질문입니다. dataGrid.fireEvent (new LoadingStateChangeEvent (LOADING/LOADED));를 사용했습니다. 하지만 효과가없는 것 같습니다. 내가 어디서 잘못한거야? – Magallo

답변

9

updateRowCount(0, false)으로 전화하면로드하는 이미지가 표시됩니다.

+1

감사합니다. 어쨌든 DataGrid에 대한 updateRowCount() 메서드를 찾을 수 없습니다. 이 방법은 무엇이라고 언급합니까? – Magallo

+0

실제로 updateRow()는 AbstractDataProvider에서 상속되고 보호되어 있으므로 호출 할 수 없습니다. 왜 보호됩니까? 다른 방법이 있습니까? – Magallo

+0

데이터 공급자가 데이터를 호출해야하기 때문에 보호됩니다. 그래서, 당신의 데이터 제공자에게 더 많은 정보를 요청할 때, DP는 즉시'updateRowCount (0, false)'를 호출 할 수 있고, 서버 콜이 돌아 오면'updateRowCount (sizeOfResult, true) '를 호출한다. –

1

내 응용 프로그램에 여러 DataGrid가 있고 아래 코드 스 니펫을 모두 사용합니다. 눈금에 레코드가 없도록 데이터를 먼저 지운 다음 행 수를 0보다 큰 숫자로 설정해야합니다. 로딩 표시기는 RPC를 통해 데이터를 수신하는 동안에 만 움직입니다. 그리드가 렌더링되면 (잠시 시간이 걸릴 수도 있음) 애니메이션이 정지됩니다.

// Only required if you are using a pager 
    int pageSize = pager.getPageSize(); 

    // This will trigger the onRangeChanged-event and call 
    // the data provider 
    dataGrid.setVisibleRangeAndClearData(new Range(0, 1), true); 
    // Together with the row above, this will show the loading-indicator 
    // in the data grid 
    dataGrid.setRowCount(1); 

    // Usually, the data is loaded when the data grid is initialized. 
    // In my application, the user has to enter some input first and 
    // then (re-)load the data via a button. 
    // If you want your data grid to be filled when it is intialized, 
    // simply remove the if-block 
    if (dataProvider.getDataDisplays().size() == 0) { 
     dataProvider.addDataDisplay(dataGrid); 
    } 

    // This will re-set the paging (only required if you are using a pager) 
    dataGrid.setPageSize(pageSize); 
0

나는이 추가 된 버전에서 잘 모르겠지만, 2.8.0-β1에 나는 비슷한 달성하기 위해 dataGrid.setRowCount(0, false)를 사용합니다.

관련 문제