Announcement

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

    How to capture selected date from the DateChooser.

    I am trying to build something similar to relative date item. I have a SelectItem with some default drop down options (like current day, pervious day) and then I used the formItemIcon option to show an icon next to this item. On click I will show a DateChooser object to pick a specfic date.
    Now there are two issues.

    1) I want to show the DateChooser next to the icon. I know that it has showNextTo method but it only takes a Canvas and FormItemIcon does not extend Canvas class.

    2) How I get the date picked by the user. I mean which event I should capture to get the selected date. I tried DataChangedHandler but not able to get the selected date.

    [Updated] I got that. I am sorry I didn't see the javadoc. It has getData method to see the selected date.

    I hope someone will reply soon. Thanks
    Last edited by asingla; 15 Jun 2010, 09:22.

    #2
    Can't you use the form as the Canvas you put it next to? How is the form laid out? With the right tweaks I'm sure you can get it placed next to the icon.

    Comment


      #3
      I have a form and there are many items in there. One of the item is to select a date. I want to show the date chooser next to this item. i didn't get what you said. I have attached the image

      Comment


        #4
        attached now.
        Attached Files

        Comment


          #5
          Well my first idea was you could assume things about the form, such as the date icon is row 2, column whatever and use item.getWidth(), item.getHeight() if you knew exactly which items to get the widths and heights of, but assuming your form may choose and you don't want to hard code things like that, you next best option is probably closer to something like.
          Code:
          final DateChooser d = new DateChooser();
          VLayout l = new VLayout();
          l.addClickHandler(new ClickHandler() {
          	@Override
          	public void onClick(ClickEvent event) {
          		if (dateClicked) {
          			d.setLeft(event.getX());
          			d.setTop(event.getY());
          			d.show();
          			dateClicked = false;
          		}
          	}
          });
          DynamicForm form = new DynamicForm();  
          FormItemIcon i = new FormItemIcon();
          i.setAttribute("id", "myicon");
          i.setSrc("add.png");
          i.addFormItemClickHandler(new FormItemClickHandler() {
          	@Override
          	public void onFormItemClick(FormItemIconClickEvent event) {
          		dateClicked = true;
          	}
          });
          SelectItem s = new SelectItem();
          s.setIcons(i);
          form.setItems(s);
          l.addMember(form);
          l.draw();
          where dateClicked is some flag you have. Again not the best but at least a bit more flexible.

          Comment


            #6
            Thanks a lot. This is the final one I am going with. Actually I know one more solution but that didn't work for me. I created a CanvasItem and add a layout canvas with 1px height and width in the CanvasItem. on click, i used this layout object in the showNextTo method of the datechooser. But adding that item to my formlayout has changed the layout of my form for that row.

            I think there are some basic problems with the DynamicForm Layout. there is no method to control width of columns for each row.

            Comment


              #7
              BTW, very smart and heckish solution. :)

              Comment


                #8
                I didn't say it was clean:) The other option would be like you tried a CanvasItem or somehow put a canvas on top of the icon and set the opacity at 100% and then use that "invisible" canvas in showNextTo()

                Comment

                Working...
                X