Announcement

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

    Unexposed API for class Calendar regarding the setCanSelectCells() method

    Hello,

    While trying to call setCanSelectCells() for a CalendarView obtained with Calendar.getMonthView() I get this error:
    "Cannot change configuration property 'canSelectCells' to true now that component isc_TestCase_MyCalendar_0_monthView has been created."

    Starting from issue #1 from topic http://forums.smartclient.com/forum/...selection-mode according to Isomorphic:
    "Some properties can only be changed before a component has been draw()n or otherwise forced to go through initialization (listGrid.fetchData(), for example, will do it). To avoid this in your code, just avoid immediately calling addMember() on the ListGrid when all you've done is new ListGrid(); configure it first."

    A CalendarView is actually a ListGrid so the same issue applies. The problem is that if you try to call that method before the calendar is draw()n the Calendar.getMonthView() returns null so the property can not be set. Should a setCanSelectCells() method be added to the class Calendar to solve this problem?

    Thank you,
    Tiberiu
    Developing applications with Smart GWT, the Google Web Toolkit edition of SmartClient

    #2
    No, because a CalendarView is a specialized ListGrid, with customized behavior for many ListGrid features, like cell-selection.

    Comment


      #3
      Then how can that method be used? Or if that method can not be used how can I select a cell for the month view of a Calendar?

      Comment


        #4
        You can't, and this is by design - as we said, CalendarViews have customized cell-selection behavior.  And it's not clear why you might want to select an arbitrary cell in a monthView - the selected date in the monthView is the calendar's chosenDate..

        You didn't mention your version, but as of SmartGWT 5.1, the current chosenDate is indeed highlighted in the monthView, if that's what you're trying to do.

        If not, what is it that you're actually after?  Just highlight a date visually, or fully select a grid-cell?  If the former, you could use a DateStyleCustomizer - if the latter, what do you expect to gain from being able to do that?
         

        Comment


          #5
          Just tested with the latest SmartGWT 5.1 version and it is better visually. It looks as if multiple dates (cells) were selected. Thanks for the tip!

          Now I also need to put my hands on those dates. Why? I shall explain. I have a regular working calendar (8 hours per day from Monday to Friday) but I also need to be able to select certain days and to mark them as non-working (special days like 4th of July etc.) See image. So how do I get those dates?

          Comment


            #6
            Made some more tests in here with SmartGWT 5.0 and the selection is displaying as with 5.1 but only on certain configurations. Find attached a test case. I am using SmartClient Version: v9.1p_2014-05-31/LGPL Development Only (built 2014-05-31) nightly build downloaded from https://www.smartclient.com/builds/S...GPL/2015-09-19 and Firefox ESR 24.6.0

            - On Mac OS X 10.10.5 it works just fine.
            - On Windows 8.1 Pro the selection is not kept.
            Attached Files

            Comment


              #7
              Hi slick07,

              the versions you mention do not match. If you are really using the download you say, make sure your browser cache is empty before calling your page.

              Best regards
              Blama

              Comment


                #8
                You didn't answer any of the questions we initially asked you.

                Also, you've now mentioned 3 different versions (5.0, 5.1 and 4.1), and the 4.1 version you mention is more than 15 months old - whichever one of those you are using will need to be updated from smartclient.com/builds.

                If you still have issues, show us a standalone minimal test-case that demonstrates your problem, and clearly describe what you want to do.

                Comment


                  #9
                  Cache problem indeed. Thanks Blama! This is what the console displays now: SmartClient Version: v10.0p_2015-09-19/LGPL Development Only (built 2015-09-19) and it behaves the same on any operating system: the selection is not remembered.

                  Isomorphic The sample TestCase shows that the selection is not kept within the calendar with the above SmartGWT version but with versions 4.1 and 5.1 the selection is kept. All I need is to see the selection when I click on cells within the month.

                  Hence I think it is a bug in version 5.0 regarding the selection and not a problem with calling setCanSelectCells() method to activate the cell selection as I assumed initially (because the cell selection is active by default).

                  Comment


                    #10
                    You've repeatedly mentioned "selecting" dates - and we say again that actual selection is a custom affair in the calendar MonthView and, as such, is NOT something you should override.

                    To re-iterate one of our earlier questions: what is it that you're actually trying to do?

                    If you want to *style* certain days, to make them stand out for whatever reason, use a DateStyleCustomizer.

                    If you want to disable dates (including styling), as you appear to be saying in a previous post, use a DisabledDateCustomizer.

                    If it's something else, please answer our questions and be clear about what you are aiming for - whatever it is, it is unlikely to be actual *selection*, particularly if it involves more than one cell.

                    Comment


                      #11
                      I am not trying to override anything. The default behavior (at least in 4.1 and 5.1) when clicking a cell in the MonthView is to display that cell with a red color (see the image from my 4th post where the 3 cells selected using ctrl-click are rendered with red color). This is what I mean by "selected" cell/date. Please run the provided TestCase with 4.1 or 5.1, click a cell and it will be rendered with red as if it is selected. Run the same test with 5.0, click a cell and it will not be rendered differently as if you did not even click that cell - it is not selected.

                      I do not need to *style* certain dates. I do not want to disable dates. I want this TestCase to work in 5.0 as it works in 4.1 or 5.1. I hope I am clear enough now...
                      Last edited by slick07; 23 Sep 2015, 05:28. Reason: Given sample image.

                      Comment


                        #12
                        Apologies, we missed the inclusion of your test-case due to an issue with a recent forums software update. And, looking at your code, it is now apparent that you are not using the calendar to manage events, as is the normal practice, but rather as a mechanism for selecting a bunch of dates for some other reason - essentially, using it as a multiple date-picker.

                        This has never been an intentional behavior of a Calendar, in any version of SmartGWT. Clicking a cell would normally create an event but, since you've disabled that functionality with setCanCreateEvents(false), it does nothing, except in 5.1, where cell-selection is intentional.

                        1) How did you select multiple cells as shown in your screenshot? We assume programatically, with selectCells() or similar, since we can't replicate that behavior in any version of SmartGWT *with the mouse*. Even in 5.1, where highlighting the chosenDate is an intentional feature, you still can't select multiple cells with the mouse (because that would make no sense - the selection represents the chosenDate). So if you were to programatically select some cells, and then click one with the mosue, we would expect that action to clear your other selections.

                        2) In which build of 4.1 do you see this selection behavior? The very old one you referred to earlier? In all versions of 4.1 recent enough for us to have retained, cell-selection *with the mouse* is disabled, even for a single cell, and whether canCreateEvents is true or false. The same is true of 5.0.

                        So, the situation is that what you're trying to do has never been intentionally supported by a SmartGWT Calendar because, coming right back to what we originally said, CalendarViews have customized cell-selection behavior.

                        However, if this is a feature you need, we may consider adding it to 5.1 via the Feature Sponsorship program.

                        Comment


                          #13
                          Indeed I am trying to select a date and preferably a multiple selection. A date-picker with dates selection would be the right description.

                          1) and 2) I selected the dates using ctrl-click with the mouse. It also works with shift-click for continuous range of selection hence nothing programatically :). For this I used SmartClient Version: v9.1p_2014-05-31/LGPL Development Only (built 2014-05-31) and Firefox ESR 24.6.0. In version 5.1 I confirm that I can select just one cell although I did not try programatically to select more.

                          Bottom line is that it never was an intentional selection (now I understand it although I thought it was a bug in 5.0 since it was available in 4.1) but I have a single cell selection in 5.1 which is enough for now. Many thanks for your time!

                          Comment

                          Working...
                          X