package com.Test.LiveGrid.client;

import com.google.gwt.core.client.EntryPoint;

import com.google.gwt.user.client.History;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.types.ListGridFieldType;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.grid.CellFormatter;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.grid.ListGridRecord;
import com.google.gwt.user.client.Cookies;
import com.smartclient.theme.silverwave.*;


import com.Test.LiveGrid.client.data.ItemSupplyXmlDS;

public class LiveGridFetchSample implements EntryPoint {
	final String initToken = History.getToken();
    public void onModuleLoad() {
    	
    	
    	
    	


        DataSource dataSource = ItemSupplyXmlDS.getInstance();

        ListGridField rowNum = new ListGridField("itemNum", "Item No.");
        rowNum.setWidth(65);
        rowNum.setCellFormatter(new CellFormatter() {
            public String format(Object value, ListGridRecord record, int rowNum, int colNum) {
                return rowNum +"";
            }
        });

        ListGridField itemName = new ListGridField("itemName", 100);
        itemName.setFrozen(true);
        ListGridField sku = new ListGridField("SKU", 100);
        ListGridField description = new ListGridField("description", 200);
        ListGridField category = new ListGridField("category", 100);
        ListGridField units = new ListGridField("units", 100);

        ListGridField unitCost = new ListGridField("unitCost", 100);
        unitCost.setType(ListGridFieldType.FLOAT);

        ListGridField inStock = new ListGridField("inStock", 100);
        inStock.setType(ListGridFieldType.BOOLEAN);

        ListGridField nextShipment = new ListGridField("nextShipment", 100);
        nextShipment.setType(ListGridFieldType.DATE);



        final ListGrid listGrid = new ListGrid();
        listGrid.setWidth100();
        listGrid.setHeight100();
        listGrid.setAutoFetchData(true);
        listGrid.setDataSource(dataSource);
        listGrid.setShowFilterEditor(true);
        

        listGrid.setFields(rowNum, itemName, sku, description, category, units, unitCost);
                            

        listGrid.draw();
        
        
        
    }
    
   

}