Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Cannot position my custom picker while editing listgrid row, column item

    Cannot place my custom picker at the row,column position of my ListGrid
    When I use the code below with a DynamicForm, the iconRect object is not null. When I use this picker on a ListGrid, the iconRect is null. Hence, I cannot get the position to display my custom picker form.

    How do I get the location on the ListGrid to display my custom picker/form?

    Environment
    v8.2p_2012-09-18/PowerEdition Deployment
    GWT-2.4

    Code Setup
    I use ListGrid.setEditorType to add my custom FormItem that has a custom picker. I have a FormItemClickHandler much like the showcase custom picker example. However, getIconPageRect gives me a null object.

    Code:
    myListGrid.getField("update").setEditorType(new FCMDateTimeItem(fname,dsf.getTitle()));
    Code:
    public class FCMDateTimeItem extends DateTimeItem {
    	private DateChooser DC;
    	private FCMDateTimeItem myself;
    
    	@SuppressWarnings({ "deprecation" })
    	private boolean isSameDay(Date d1, Date d2) {
    		return d1.getYear() == d2.getYear() && d1.getMonth() == d2.getMonth()
    				&& d1.getDate() == d2.getDate();
    	}
    
    	private void init()
    	{
    		myself = this;
    
    		DC = new DateChooser();
    		DC.addDataChangedHandler(new DataChangedHandler() {
    			@SuppressWarnings("deprecation")
    			@Override
    			public void onDataChanged(
    					com.smartgwt.client.widgets.events.DataChangedEvent event) {
    				DC.hide();
    				Date now = new Date();
    				Date date = DC.getData();
    				if (myself.isSameDay(now, date)) {
    					date = now;
    				} else {
    					date.setHours(0);
    					date.setMinutes(0);
    					date.setSeconds(0);
    				}
    				// SC.say("Date in setData() :"+date+"<--> Date using getData()"+DC.getData());
    				DC.setData(date);
    				myself.setValue(date);
    			}
    		});
    		DC.setShowCancelButton(true);
    		DC.setCancelButtonTitle("Cancel");
    		DC.setTodayButtonTitle("Now");
    
    		PickerIcon datePicker = new PickerIcon(PickerIcon.DATE,
    				new FormItemClickHandler() {
    
    					@Override
    					public void onFormItemClick(FormItemIconClickEvent event) {
    						FormItemIcon fii = event.getIcon();
    						Rectangle iconRect = getIconPageRect(fii);
    						if(null != iconRect)
    						{
    							DC.setLeft(iconRect.getLeft());
    							DC.setTop(iconRect.getTop());
    						}
    						else
    						{
    							//TODO: how to get position for ListGrid
    						}
    						DC.show();
    					}
    				});
    
    		this.setShowPickerIcon(false);
    		setIcons(datePicker);
    	}
    	public FCMDateTimeItem() {
    		init();
    	}
    	public FCMDateTimeItem(String name, String title) {
    		super(name,title);
    		
    		init();
    	}
    
    }
Working...
X