2013-02-09 1 views
2

일부 스프레드 시트 데이터가 필요한 UiApp 양식이 있습니다 (검색 속도가 느림). 내가 뭘 달성하고 싶습니다 평소처럼보기를로드하고 그것이 완료되면 데이터를 가져오고 내보기를 업데이 트하는 서버 처리기를 호출과 같은 뭔가를 할 표시됩니다. 그게 가능하니?UiApp로드 후 함수 호출 (자바 스크립트 onLoad 해당)

나는 주변을 둘러 보았지만 아무 것도 찾지 못했습니다. ...

this에 따르면, "기능의 doGet (e)는의 onLoad의 GWT의 동일합니다",하지만 난 페이지를 dispay 싶습니다 및 은 다음가 느린 부분을 같이 내 사건에없는

답변

4

Stumbled on this 우리는 pseudo-onLoad 이벤트를 구현하는 데 사용할 수 있습니다.

체크 상자의 setValue 기능은 an optional parameter이며 valueChanged 처리기가 발생합니다. 따라서 프로그래밍 방식으로 valueChanged 핸들러를 트리거 할 수 있습니다.이 핸들러를 사용하면 핸들러가 동시에 호출되는 동안 앱을 리턴 (초기로드) 할 수 있습니다.

function doGet() { 
    var app = UiApp.createApplication(); 

    var label = app.createLabel('Loading the data from the spreadsheet.') 
       .setId('statusLabel') 
    app.add(label); 

    var handler = app.createServerHandler('loadData'); 
    var chk = app.createCheckBox('test').addValueChangeHandler(handler).setVisible(false).setValue(true,true).setId('chk'); 
    app.add(chk); 

    return app; 
} 

function loadData(e) { 
    var app = UiApp.getActiveApplication(); 

    Utilities.sleep(3000); //placeholder for some function that takes a long time. 

    var label = app.getElementById('statusLabel'); 
    label.setText("Loaded the data from the spreadsheet"); 

    return app; 
} 
+0

정말 좋은 방법입니다 .-) 아마도 checkBox의 [부드러운 트리거 기능]에 대한 설명을 추가 할 수 있습니다 (https://developers.google.com/apps-script/class_checkbox?hl=en# setValue) –

+0

독창적 인 해결 방법과 매력처럼 작동합니다. 고맙습니다! –

0

다른 위젯에는 setValue(value, fireEvents) 개의 메소드가 있습니다. TextBox, PasswordTextBox 등이 기술을 구현할 때 CheckBox 위젯에 대해 고유 한 것이없는 것처럼 보입니다.

관련 문제