package com.retrievead.client;

import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSCallback;
import com.smartgwt.client.data.DSRequest;
import com.smartgwt.client.data.DSResponse;
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.types.Overflow;
import com.smartgwt.client.widgets.form.DynamicForm;
import com.smartgwt.client.widgets.form.fields.TextItem;
import com.smartgwt.client.widgets.form.fields.events.EditorExitEvent;
import com.smartgwt.client.widgets.form.fields.events.EditorExitHandler;
import com.smartgwt.client.widgets.grid.ListGrid;
import com.smartgwt.client.widgets.grid.ListGridField;
import com.smartgwt.client.widgets.layout.VLayout;


public class FrmMainSearch extends VLayout {
	protected VLayout main = new VLayout();
	protected DefaultDynamicForm frmsearch2 = new DefaultDynamicForm();
	protected DefaultDateItem spubdate;
	public FrmMainSearch(){

		setWidth100();
    	setHeight100();
    	setOverflow(Overflow.AUTO);
    	main.setWidth100();
    	main.setHeight100();

        DataSource customDS = DataSource.get("mHoliday");  
        
        final ListGrid userList = new ListGrid();  
        userList.setWidth(600);  
        userList.setHeight(224);  
        userList.setDataSource(customDS);  
        userList.setCanEdit(true);  
        userList.setAutoFetchData(true);  
        ListGridField testA = new ListGridField("NAME","TEST A");
        userList.setFields(  
                testA,
                new ListGridField("EDIT_BY", "TEST B")
                );  
        
        testA.addEditorExitHandler(new com.smartgwt.client.widgets.grid.events.EditorExitHandler(){

			@Override
			public void onEditorExit(com.smartgwt.client.widgets.grid.events.EditorExitEvent event) {
				DataSource.get("mHoliday").fetchData(new Criteria(), new DSCallback(){

					@Override
					public void execute(DSResponse dsResponse, Object data, DSRequest dsRequest) {
						// TODO Auto-generated method stub
						
					}
					
				});
			}
        	
        });
        main.addMember(userList);  
        
        DynamicForm frm = new DynamicForm(); 
        TextItem test1 = new TextItem();
        test1.setWidth(100);
        test1.setTitle("TEST 1");
        test1.addEditorExitHandler(new EditorExitHandler(){

			@Override
			public void onEditorExit(EditorExitEvent event) {
				DataSource.get("mHoliday").fetchData(new Criteria(), new DSCallback(){

					@Override
					public void execute(DSResponse dsResponse, Object data, DSRequest dsRequest) {
						// TODO Auto-generated method stub
						
					}
					
				});
			}
        	
        });
        TextItem test2 = new TextItem();
        test2.setWidth(100);
        test2.setTitle("TEST 2");
        frm.setItems(test1,test2);

        main.addMember(frm);  
    	
       	addMember(main);
	}
	

	
}

