Announcement

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

    Issue with date picker after upgrade from SmartClient 10 to SmartClient 12.1

    Hi,

    I recently upgraded from SmartClient 10 to 12.1, since then I have difficulty in date picker.
    After initial debugging, in the working code(Version 10) I can see that when I clicked on date picker icon,
    function iconClick is getting called which eventually calls this.showPicker(). I can also see
    that show function is getting called from picker. However, in 12.1 eventhough function iconClick
    is called after date picker clici, show function inside picker NOT getting called which I suspect
    is the reason for date picker not being shown. Below is the snipper of code.


    {name: "myDate", editorType: "SelectItem", showTitle: false, valueMap:myData.getDateValues(myData.defaultVal),
    showPickerIcon: true, width:150, defaultValue: "Current",
    icons: [{src: "[SKIN]/pickers/date_picker.png"}], redrawOnChange:true,
    iconClick: function(){
    this.showPicker();
    },
    change: function(form, item, value, oldValue ) {

    this.Super("change", arguments);
    },
    picker: isc.DateChooser.create({autoDraw: false,
    dataChanged: function() {
    // To handle date change scenario
    },
    show : function() {
    // NOT GETTING CALLED!!!
    this.Super("show", arguments);
    }
    }),
    setValue : function(value) {
    // some custom code
    this.Super("setValue", value);
    }
    },

    I would like to know whether any changes are required for date picker after version upgrade.
    In version 10 of SmartClient above code works perfectly. Problem started after upgrade to version 12.1

    Any suggestions or pointers are highly appreciated.

    #2
    Hello Karthi, it looks like you have been relying on undocumented behavior, in a few ways: overriding the default picker with your own, expecting show() to be called at a particular time, etc.

    When you rely on undocumented behavior, you should generally expect your code to break when you upgrade (this is true of all software, not just SmartClient).

    You haven't told us anything about what you were trying to accomplish with this code, so at the moment, it's not possible to help. Please see the Debugging overview to get a clear idea of the information you need to share, in order to make it possible to help you.

    Comment


      #3
      Ideally I expected backward compatibility. I am trying to achieve SelectItem with child of DateChooser as in the above snippet. Can you point me to some example where SelectItem contains a child of DateChooser? In documentation I only got Java references however I need JavaScript example since my legacy code is written in JS directly which is broken now.

      Comment


        #4
        "Backwards compatibility" means compatibility with documented behaviors. We have achieved actual backwards compatibility for many releases. You simply relied upon undocumented behaviors (in multiple areas, as explained above) and so your code broke, as is a predictable and normal result of relying on undocumented behaviors.

        We're not sure why you refer to "only got Java references", but here is a correct link to the SmartClient Reference. Make sure you have read the QuickStart Guide as well (the first link in the tree on the left).

        As far as combining SelectItem and DateChooser, you can use a FormItemIcon (via formItem.icons) to create a DateChooser on iconClick on an icon. You haven't given us any further information on your use case or intended result, but if you approach things this way, you can avoid relying on undocumented behavior (note that the Using AutoChildren overview can help you understand what is a valid, supported override vs going too far, as you have in this case).

        Comment


          #5
          May be I didn't explained clearly. If I have SelectItem along with DateChooser as it's child, when iconClick is called, instead of opening date chooser, select item drop down is getting opened. This is happening even if I click on down array on select item as well as on dater picker icon. I am able to resolve this by having to different methods for select item click and picker icon click 'iconClick' and 'pickerIcionClick' and used child reference's show function. Now date chooser is showing up, but at the top left corner of the page. I'm tring to position it to next to Select Item like before. Any pointers will be appreciated.

          Comment


            #6
            Again, you can't just override the picker autoChild of the SelectItem. You can add a picker to a FormItem but for the SelectItem the picker autoChild system is already in use.

            So, as we explained, you can create your own FormItemIcon that launches a DateChooser. You can then hide the default drop-down icon via showPickerIcon:false. But do not try to assign something to the "picker" AutoChild.

            Comment


              #7
              I get your point. However, when DateChooser is added to SelectItem and select item's 'showPicker' is called, which picker will be shown (SelecteItem's picker or Date Chooser's picker which is calendar popup?) This is my original issue, when used with SmartCLient 10, in anbove code showPIcker nicely opened calendar but after upgrade to 12, clicking on calendar icon opening SelectItem instead of date chooser.

              Also, another weird behavior I noticed is, even though I have two functions defined iconClick & pickerIconClick, supposed to invoke when clicked on icon and picker icon, somehow pickerIconClick not invoking, it is always invoking iconClick even I click on drop down down arrow (picker icon) and calendar icon (icon). As a result, when I click on selectitem down arrow icon, both drop down and calendar getting opened.

              Overall, my question is in version 12, were there any changes to UI related events, behavior that is causing perfecting working code to break after upgrade. I felt at times open source free jQuery is much easier to tackle than commercial licensed SmartClient.
              Last edited by karthikaple282; 23 Mar 2022, 19:18.

              Comment


                #8
                Yes, as previously explained (see post above about the Using AutoChildren overview), there are specific guidelines in the docs that explain what is safe to use and what is not. According to those guidelines, you clearly went into an area that was not safe for forward compatibility.

                The documentation we referenced is unambiguous on this point, and we wrote this documentation to try to prevent the problem you are now experiencing.

                Further, the reason that we provide these guidelines is because the undocumented, unsupported behaviors of components will often change, over time, by necessity, as we add new features (for example, automatic mobile adaptation) or as we deal with the changes in underlying browser technology (where they are often very bad about backwards compatibility - we do try to shield you from that).

                It is absurd to compare us to JQuery - that is like comparing assembly language to Kotlin - but it doesn't matter what library you are using - if you violate the docs regarding forward compatibility, your code will break.

                We did our best to warn you of what would happen if you ignored the forward compatibility guidelines we laid out. Your broken code is a predictable result of not paying attention to that documentation. Simply fix it, using the guidance we have provided, and it will not break again, as it would not have broken had it been written that way before.

                Comment


                  #9
                  I had a discussion internally within team, below is my exact requirement.

                  i) I need to have a drop down (SelectItem) with two options initially (Current Day, Previous Day). The units whether day, week, month, year changes based on Radio Button group, that's taken care of.

                  ii) Next to SelectItem I need calendar icon upon clicking need to open DateChooser. Use case is, user either selects current day or previous day or any specific day).

                  Now, in existing code we achieved this by creating SelectItem and making DateChooser as it's child. Also, 'show' function of DateChooser is overriden in order to set some values which required in other parts of code.

                  #####Based on your earlier comments ... I have couple of questions.
                  " you can use a FormItemIcon (via formItem.icons) to create a DateChooser on iconClick on an icon"
                  Q: Are you suggesting to create DateChooser as a separate widget instead of child of SelectItem?

                  "you can create your own FormItemIcon that launches a DateChooser. You can then hide the default drop-down icon via showPickerIcon:false."
                  Q: If I hide default drop-down icon, how user will know that I have Current/Previous options? So drop-down down arrow must be shown.

                  Q: Another different behavior I noticed with DateaChooser is, it's NOT closing upon loosing focus. (It closes with older version before upgrade). Is there any event I can override and close it? I tried calling hide() inside blur() to close it, but it didn't work.

                  Comment


                    #10
                    1. Yes. Note that your previous attempt to override the "picker" autoChild also did not create the DateChooser as a child. It's just a related widget. We have been saying: do the same thing, just stop relying on undocumented behaviors of the internal "picker" autoChild.

                    2. If you want a drop-down that has Current/Previous options, then simply create a SelectItem that has Current and Previous options. Nothing is stopping you. Also, multiple FormItems, or any other widgets, can be combined into a single component that behaves as a FormItem (contributes a value to a surrounding form). See CanvasItem, and the related samples.

                    3. Automatic dismissal is another way in which you were be relying on the internal, undocumented behavior of internal pickers. You will notice that widgets in general do not spontaneously disappear when they lose focus (imagine if all grids did that!). If you want a widget to disappear when it loses focus, you do have to implement that, and it's quite straightforward. To do so, look at the clickmask APIs and look at Page.setEvent() if you are trying to globally capture clicks.

                    Also, you didn't flag it as a question (with a "Q:" at the beginning), but, if you are no longer trying override the internal details of the built-in picker, you no longer have to try to add logic in the show() method of the picker. You just execute such logic wherever you show the DateChooser, which is entirely under your control.

                    Overall, your use case is quite straightforward, and can be achieved with well-documented APIs. Just do it in a documented way, and it will never break again.

                    Finally, please do not create duplicate threads about this same thing (we have already deleted the other thread for you).

                    Comment

                    Working...
                    X