Setting the DatePicker

It’s been a wee while since my last post – time being sucked up by a new AS400 and various other non-M3 issues that I’ve needed to address…but most of those issues are now resolved so back to jscripts.

I got an email last night requesting some help about setting the Date field within CAS950. The person was setting the Text property of the control but nothing was happening. The Text property was a valid property in the control, but didn’t appear to have any effect.

Personally having had experienced similar frustration with Date Pickers from .Net I had a suspicion on what the issue was.

First thing that I did was find out what the control type was. As illustrated before I grab the control and do a GetType(), then I used Visual Studio to take a look at what methods and properties are available.

And we see a Value property which takes a System.DateTime – looks very promising!

A quick test, and yup, it was correct.

The code is below:





import System;
import System.Windows;
import System.Windows.Controls;

import MForms;

package MForms.JScript
{
   class cas950

   {
      public function Init(element: Object, args: Object, controller : Object, debug : Object)
      {

            var content : Object = controller.RenderEngine.Content;
            
            // TODO Add your code here
            var WFTRDT = ScriptUtil.FindChild(content, "WFTRDT");
            var dtCurrent : DateTime = DateTime.Now;
            
            WFTRDT.Value = dtCurrent;
            MessageBox.Show(WFTRDT.GetType());
      }
   }
}

 

Happy coding! 🙂

This entry was posted in Development, M3 / MoveX and tagged . Bookmark the permalink.

9 Responses to Setting the DatePicker

  1. Patrick Weiss says:

    Hi Potato IT?

    I use this reply for asking something else. Is it possible to include a new field in a sub-file (B-Panel) ?

    • potatoit says:

      Hi Patrick,

      not enough coffee this morning, so if I haven’t grasped your question…

      Yes, you can add new controls to the B-panel. I don’t think that you’d want to add a new column to any of the existing M3 tables however – this will just bring about tears when you upgrade 😉

      There is of-course no reason that you can’t create your own database and use a jscript to write out information from these additional fields to a database and table of your own creation – be aware of potential performance implications. It’s also worth noting – I’ve been told that LPD strongly discourage using direct database calls to the M3 databases in jscripts due to potential caching data issues. If people want to use db calls to the M3 database then they should wrap the SQL in a webservice through LWS Designer.

      Cheers,
      Scott

      • Patrick Weiss says:

        Hi Scott,
        sorry, my question was not clear. I don’t need to create a new field in a DB table, but just display an additional information in a B-Panel, for ex. in MNS150 the date format behind the initial Menu in each line

        Regards
        Patrick

      • potatoit says:

        Hi Patrick,

        yes, you certainly can but you will need to use WebServices to obtain the data 🙂

        If you are looking at the date format specifically then if you take a look at the UserAndProfileExample.js in the lsodg-w-m3.pdf it will show you how to extract that information from the runtime without creating WebServices.

        Cheers,
        Scott

      • Patrick Weiss says:

        Hi Scott,
        my problem is not how to fetch the data (WebServices, etc…) but to put a new column in the list on the B-panel.
        I know how to extract information using controller.RenderEngine.ListControl.ListView/Columns etc…, but not how to add a new columns in an existing list.

        regards
        Patrick

      • potatoit says:

        Hi Patrick,

        There is a really good detailed explanation from Thibaud here:
        http://thibaudatwork.wordpress.com/2011/09/22/how-to-add-a-column-to-a-list/
        be sure to read through the comments.

        Cheers,
        Scott

      • Patrick Weiss says:

        Hi Scott,

        yes, it’s exactly want i need.

        Thx

  2. Sam N says:

    Hi Scott,

    I have inserted a new date-picker field in PPS200 because business wanted to capture Bill Of Lading date.

    var dateF1 = new DatePicker();

    My problem is that I am just not able to get the format of my date picker field to match the format of existing M3 datepicker fields (from the theme). Especially the calendar icon. I have tried things like –

    dateF1.Button.Style = StyleManager.Button.StyleDatePicker;
    dateF1.Style = StyleManager.StyleDatePicker;

    Its just not working. How do I force the field to have the same format as my theme.

    Thanks.

    Sam.

    • potatoit says:

      Hi Sam,

      I would have expected the StyleManager.StyleDatePicker to have worked. But…

      try taking a look at the Mango.UI.Controls.DatePicker – I’m not in a position to check at the moment but that may be what you’re looking for. If not, let me know and I’ll do some digging.

      Cheers,
      Scott

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s