package com.mycompany.client;

import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.smartgwt.client.widgets.layout.HLayout;

public class TestListGrid extends ListGrid implements EntryPoint {

	public void onModuleLoad() {
        ListGridField institutionCodeField = new ListGridField("institutionCode", "Code", 50);
        ListGridField serviceNameField = new ListGridField("serviceName", "Service");
        ListGridField shortAddressField = new ListGridField("shortAddress", "Address");
        ListGridField nodeTypeField = new ListGridField("nodeType", "Type");
                
        /* specify which fields to display on grid */
        setFields(institutionCodeField, serviceNameField, shortAddressField, nodeTypeField);

        // setup datasource
        ServiceNodeDataSource dataSource = new ServiceNodeDataSource();
        setDataSource(dataSource);
        this.invalidateCache();
        this.fetchData();		
        
        HLayout topPane = new HLayout();
        topPane.setHeight100();
        topPane.setWidth100();
        
        topPane.addMember(this);
        
		ListGridRecord[] nodes = this.getRecords();
		System.out.println("nodes.length = " + nodes.length);
        
		// Add image and button to the RootPanel
		RootPanel.get("grid").add(topPane);        
	}

}
