Forum Discussion

_os21's avatar
_os21
Frequent Visitor
3 years ago

Custom Visual - how to define formattingSettings.DatePicker in capabilities.json

I'm trying to use the date picker but cannot link the capabilities.json type to the Date type variable in the value, so even though I can select a date in the format pane, it won't save like other parameters.

 

In settings.ts the code is :

 

 

    payRefDate = new formattingSettings.DatePicker({
        placeholder: "Pay Period Reference Date",
        name: "payRefDate",
        displayName: "Pay period start",
        description: "Pay period seed reference date from which to start the repeating period",
        value: new Date(2023,0,1)  // this does not initialise the picker
    });

 

 

 

and the capabilities.json has (unsatisfactorily):

 

 

        "pay": {
            "properties": {
                "payRefDate": { 
                    "displayNameKey": "payRefDate",
                    "type": {"text": true}
                }
              }
            }

 

 

How do I access the extended ValueTypeDescriptor types in capabilites.json or is there a simpler way to get the date picker to work?

2 Replies

  • dm-p's avatar
    dm-p
    Super User

    Hi _os21

    This is an interesting one. I haven't tried it yet, but have had a look following your post, and have drawn the same conclusions as you, I think.

    The permitted property types in capabilities.json are fairly primitive, and date is not a supported type in here. It's not possible to include conditional formatting measures that use the date or date/time data type either (just text or numeric).

    You may be better contacting the team - [email protected] - for clarification on whether this is actually supported, and if so, whether they have any guidance that they can offer on it.

    Regards,

    Daniel

     

    P.S. here's my research, just to see if it lines up with yours:

    • With the new formatting cards (introduced in API 5.1), the data picker is not listed in the supported control types for property slices in the documentation, although there is a definition in the API for it.
    • Best I can tell is if you create a property with type "text", you can create a slice that utilises FormattingComponent.DatePicker, but it doesn't seem to work well, so I would assume that it's not yet fully supported. For example, this presents the date picker control:
    • And this will store a value in the data view (but this is a stringified date/time), e.g.:
    • However, this does not parse back when processing the settings, so it looks like the types are not compatible.

     

    • _os21's avatar
      _os21
      Frequent Visitor

      Thanks for this... the doc points one to the github so it's "sort of" documented! The whole formattingModel & PBIVIZ stuff is terribly documented... confused and inconsistent.