2010-10-20 60 views
0

填充ListGridFields這是我的代碼片段:在SmartGWT的

final ListGrid subscriberGrid = new ListGrid(); 
    subscriberGrid.setWidth(500); 
    subscriberGrid.setHeight(224); 
    subscriberGrid.setShowAllRecords(true); 
    subscriberGrid.setSelectionType(SelectionStyle.SIMPLE); 
    subscriberGrid.setSelectionAppearance(SelectionAppearance.CHECKBOX); 

    ListGridField fnField = new ListGridField("fn", "First Name"); 
    ListGridField lnField = new ListGridField("ln", "Last Name"); 
    ListGridField emailField = new ListGridField("email", "E-mail"); 
    subscriberGrid.setFields(fnField, lnField, emailField); 

如何輸入值呢?我嘗試啓動一個ListGridRecord [],但我無法正確填充任何值。我也嘗試過一個Javascript對象,但那也給了我一個錯誤。谷歌搜索也沒有返回滿意的結果。

TIA。

回答

2

ahh Darn。我問了這個問題後得到了答案。

 ListGridRecord temp = new ListGridRecord(); 

     temp.setAttribute("fn", "foo"); 
     temp.setAttribute("ln", "bar"); 
     temp.setAttribute("email", "baz"); 

     ListGridRecord[] record = { temp }; 

     subscriberGrid.setData(record); 

很抱歉的混亂^ -^