Formatting dates and numbers in a Mashup

Lawson Smart Office comes with a set of converters developed for making formatting issues easier in Mashups. Much formatting can be done using StringFormat and this is standrad WPF. But if you want to use the M3 user’s format or if you want to surpress Zero there are converters that we have developed for you.

The converters are documented in the SDK Documentation found in the Mashup Designer under Help (9.1.3).

For a short date format in a MIList binding use the following syntax:

"{Binding [FVDT], StringFormat=d}"

For an overview of different standard formatters read http://msdn.microsoft.com/en-us/library/26etazsy.aspx.

Converters are used to convert one type to another type. In this case we are converting double and DateTime to string. In LSO we have made the M3 converters available in 9.1.3 (I think). You have to check your version to see if the mashup below works or gives you an exception that the converter cannot be found.

There are two options when it comes to the syntax of using the converter. You can use it as a markup extension or as a static resource reference. (Both assume that you have declared the namespace m3 or mashup depending on which converter you use.)

Markup extension

<TextBlock Name="textBlock" Text="TextBlock with a double width" Width="165.3"/>
<!-- Markup extension-->
<TextBlock Text="{Binding ElementName=textBlock,Path=Width, Converter={m3:M3DoubleConverter}}" HorizontalAlignment="Left" />

Referenced as a static resource

<Grid.Resources>
  <m3:M3DoubleConverter x:Key="m3DoubleConverter" />
</Grid.Resources>
<TextBlock Name="textBlock" Text="TextBlock with a double width" Width="165.3"/>
<!-- Markup extension-->
<TextBlock Text="{Binding ElementName=textBlock,Path=Width, Converter={StaticResource m3DoubleConverter}}" HorizontalAlignment="Left" />

In the markup extension there is no need to add the resource but you are not able to configure the Converter. For doubles we have a Converter that is in the same namespace as Mashups. It is possible to set a NumberFormat, NumberFormatInfo and SurpressZero.

<Grid.Resources>
  <mashup:DoubleConverter x:Key="doubleConverter" />
  <mashup:DoubleConverter x:Key="doubleConverterSuppressZero" SuppressZero="True" />
   <!-- Using the numberformat from M3-->
  <mashup:DoubleConverter x:Key="doubleConverterWithInfo" NumberFormatInfo="{x:Static m3:M3Format.NumberFormat}" />
  <mashup:DoubleConverter x:Key="doubleConverterWithFormat" NumberFormat="n" />
</Grid:Resources>

In order to demonstrate different formats I have a number of Mashups done by Peter. First comes a Mashup with two identical lists of customers, but the credit limits are formatted differently.

Here is the XAML:

<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ui="clr-namespace:Mango.UI.Controls;assembly=Mango.UI" xmlns:mashup="clr-namespace:Mango.UI.Services.Mashup;assembly=Mango.UI" xmlns:m3="clr-namespace:MForms.Mashup;assembly=MForms">

  <Grid.Resources>
    <!-- Enables SupressZero and overrides the default number format -->
    <m3:M3DoubleConverter x:Key="m3DoubleConverter" SuppressZero="True" NumberFormat="n2" />
    <m3:M3DateConverter x:Key="m3DateConverter" />
  </Grid.Resources>

  <Grid.ColumnDefinitions>
    <ColumnDefinition Width="*" />
  </Grid.ColumnDefinitions>
  <Grid.RowDefinitions>
    <RowDefinition Height="Auto" />
    <RowDefinition Height="*" />
    <RowDefinition Height="Auto" />
    <RowDefinition Height="*" />
    <RowDefinition Height="Auto" />
  </Grid.RowDefinitions>

  <!-- Using converter created with a markup extension -->
  <m3:MIListPanel Grid.Row="1" Name="customerList" Margin="8">
    <m3:MIListPanel.Events>
      <mashup:Events>
        <mashup:Event SourceEventName="Startup" />
      </mashup:Events>
    </m3:MIListPanel.Events>
    <m3:MIListPanel.DataSource>
      <m3:MIDataSource Program="CRS610MI" Transaction="LstByNumber" Type="List" InputFields="CUNO" OutputFields="CUNO,CUNM,CRLM,TDIN" />
    </m3:MIListPanel.DataSource>
    <ListView ItemsSource="{Binding Items}" Style="{DynamicResource styleListView}" ItemContainerStyle="{DynamicResource styleListViewItem}">
      <ListView.View>
        <GridView ColumnHeaderContainerStyle="{DynamicResource styleGridViewColumnHeader}">
          <GridView.Columns>
            <GridViewColumn Header="Customer number" DisplayMemberBinding="{Binding [CUNO]}" />
            <GridViewColumn Header="Customer name" DisplayMemberBinding="{Binding [CUNM]}" />
            <GridViewColumn Header="Credit limit 1 - max overdue invoices" DisplayMemberBinding="{Binding [CRLM], Converter={m3:M3DoubleConverter}}" />
            <GridViewColumn Header="Overdue invoice amount" DisplayMemberBinding="{Binding [TDIN], Converter={m3:M3DoubleConverter}}" />
          </GridView.Columns>
        </GridView>
      </ListView.View>
    </ListView>
  </m3:MIListPanel>

  <!-- Using converter defined as a resource  -->
  <m3:MIListPanel Grid.Row="3" Name="customerList2" Margin="8">
    <m3:MIListPanel.Events>
      <mashup:Events>
        <mashup:Event SourceEventName="Startup" />
      </mashup:Events>
    </m3:MIListPanel.Events>
    <m3:MIListPanel.DataSource>
      <m3:MIDataSource Program="CRS610MI" Transaction="LstByNumber" Type="List" InputFields="CUNO" OutputFields="CUNO,CUNM,CRLM,TDIN" />
    </m3:MIListPanel.DataSource>
    <ListView ItemsSource="{Binding Items}" Style="{DynamicResource styleListView}" ItemContainerStyle="{DynamicResource styleListViewItem}">
      <ListView.View>
        <GridView ColumnHeaderContainerStyle="{DynamicResource styleGridViewColumnHeader}">
          <GridView.Columns>
            <GridViewColumn Header="Customer number" DisplayMemberBinding="{Binding [CUNO]}" />
            <GridViewColumn Header="Customer name" DisplayMemberBinding="{Binding [CUNM]}" />
            <GridViewColumn Header="Credit limit 1 - max overdue invoices" DisplayMemberBinding="{Binding [CRLM], Converter={StaticResource m3DoubleConverter}}" />
            <GridViewColumn Header="Overdue invoice amount" DisplayMemberBinding="{Binding [TDIN], Converter={StaticResource m3DoubleConverter}}" />
          </GridView.Columns>
        </GridView>
      </ListView.View>
    </ListView>
  </m3:MIListPanel>

  <m3:MIPanel Grid.Row="4" Name="customerDetail" Margin="8,24,8,8">
    <m3:MIPanel.Events>
      <mashup:Events>
        <mashup:Event SourceName="customerList" SourceEventName="CurrentItemChanged">
          <mashup:Parameter SourceKey="CUNO" TargetKey="CUNO" />
        </mashup:Event>
        <mashup:Event SourceName="customerList2" SourceEventName="CurrentItemChanged">
          <mashup:Parameter SourceKey="CUNO" TargetKey="CUNO" />
        </mashup:Event>
      </mashup:Events>
    </m3:MIPanel.Events>
    <m3:MIPanel.DataSource>
      <m3:MIDataSource Program="CRS610MI" Transaction="GetBasicData" Type="Get" InputFields="CUNO" OutputFields="CUNO,CUNM,LMDT" />
    </m3:MIPanel.DataSource>
    <Grid>
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="8" />
        <ColumnDefinition Width="200" />
        <ColumnDefinition Width="16" />
        <ColumnDefinition Width="*" />
      </Grid.ColumnDefinitions>
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
      </Grid.RowDefinitions>
      <Label Content="Customer number:" Grid.Row="0" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center" />
      <TextBox MaxLength="10" Text="{Binding [CUNO]}" Grid.Row="0" Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Center" />
      <Label Content="Customer name:" Grid.Row="1" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center" />
      <TextBox MaxLength="36" Text="{Binding [CUNM]}" Grid.Row="1" Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Center" />

      <!-- Using converter created with a markup extension -->
      <Label Content="Change date for customer:" Grid.Row="2" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center" />
      <TextBox MaxLength="10" Text="{Binding [LMDT], Converter={m3:M3DateConverter}}" Grid.Row="2" Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Center" />

      <!-- Using converter defined as a resource -->
      <Label Content="Change date for customer:" Grid.Row="3" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center" />
      <TextBox MaxLength="10" Text="{Binding [LMDT], Converter={StaticResource m3DateConverter}}" Grid.Row="3" Grid.Column="2" HorizontalAlignment="Stretch" VerticalAlignment="Center" />

    </Grid>
  </m3:MIPanel>
</Grid>

Example with numeric formatting

<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ui="clr-namespace:Mango.UI.Controls;assembly=Mango.UI" xmlns:mashup="clr-namespace:Mango.UI.Services.Mashup;assembly=Mango.UI" xmlns:m3="clr-namespace:MForms.Mashup;assembly=MForms" xmlns:sys="clr-namespace:System;assembly=mscorlib">
  <Grid.Resources>
    <mashup:DoubleConverter x:Key="doubleConverter" />
    <mashup:DoubleConverter x:Key="doubleConverterSuppressZero" SuppressZero="True" />
    <mashup:DoubleConverter x:Key="doubleConverterWithInfo" NumberFormatInfo="{x:Static m3:M3Format.NumberFormat}" />
    <mashup:DoubleConverter x:Key="doubleConverterWithFormat" NumberFormat="n" />
    <m3:M3DoubleConverter x:Key="m3DoubleConverter" />
  </Grid.Resources>

  <StackPanel>
    <TextBlock Name="textBlock" Text="TextBlock with a double width" Width="165.3" Background="Silver" Margin="0,0,0,8" HorizontalAlignment="Left" FontWeight="Bold" />

    <TextBlock Text="StringFormat only, no converter:" HorizontalAlignment="Left" FontWeight="Bold" />
    <TextBlock Text="{Binding ElementName=textBlock,Path=Width, StringFormat=n}" HorizontalAlignment="Left" />
    <TextBlock Text="{Binding ElementName=textBlock,Path=Width, StringFormat=c}" HorizontalAlignment="Left" />

    <TextBlock Text="DoubleConverter markup extension:" HorizontalAlignment="Left" FontWeight="Bold" />
    <TextBlock Text="{Binding ElementName=textBlock,Path=Width, Converter={mashup:DoubleConverter}}" HorizontalAlignment="Left" />
    <TextBlock Text="{Binding ElementName=textBlock,Path=Width, Converter={mashup:DoubleConverter}, ConverterParameter=n}" HorizontalAlignment="Left" />
    <TextBlock Text="{Binding ElementName=textBlock,Path=Width, Converter={mashup:DoubleConverter}, ConverterParameter=e}" HorizontalAlignment="Left" />

    <TextBlock Text="DoubleConverter resource:" HorizontalAlignment="Left" FontWeight="Bold" />
    <TextBlock Text="{Binding ElementName=textBlock,Path=Width, Converter={StaticResource doubleConverter}}" HorizontalAlignment="Left" />
    <TextBlock Text="{Binding ElementName=textBlock,Path=Width, Converter={StaticResource doubleConverter}, ConverterParameter=n}" HorizontalAlignment="Left" />
    <TextBlock Text="{Binding ElementName=textBlock,Path=Width, Converter={StaticResource doubleConverterSuppressZero}}" HorizontalAlignment="Left" />
    <TextBlock Text="{Binding ElementName=textBlock,Path=Width, Converter={StaticResource doubleConverterWithInfo}}" HorizontalAlignment="Left" />
    <TextBlock Text="{Binding ElementName=textBlock,Path=Width, Converter={StaticResource doubleConverterWithFormat}}" HorizontalAlignment="Left" />

    <TextBlock Text="M3DoubleConverter markup extension:" HorizontalAlignment="Left" FontWeight="Bold" />
    <TextBlock Text="{Binding ElementName=textBlock,Path=Width, Converter={m3:M3DoubleConverter}}" HorizontalAlignment="Left" />

    <TextBlock Text="M3DoubleConverter resource:" HorizontalAlignment="Left" FontWeight="Bold" />
    <TextBlock Text="{Binding ElementName=textBlock,Path=Width, Converter={StaticResource m3DoubleConverter}}" HorizontalAlignment="Left" />

    <TextBlock Text="TwoWay binding:" HorizontalAlignment="Left" FontWeight="Bold" />
    <TextBox Text="{Binding Mode=TwoWay, ElementName=textBlock, Path=Width, Converter={StaticResource doubleConverterWithInfo}}" HorizontalAlignment="Left" />

    <TextBox Text="{Binding Mode=TwoWay, ElementName=textBlock, Path=Width, Converter={StaticResource doubleConverter}}" HorizontalAlignment="Left" />

  </StackPanel>

</Grid>

Example with dates

<Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ui="clr-namespace:Mango.UI.Controls;assembly=Mango.UI" xmlns:mashup="clr-namespace:Mango.UI.Services.Mashup;assembly=Mango.UI" xmlns:m3="clr-namespace:MForms.Mashup;assembly=MForms">
  <Grid.Resources>
    <mashup:DateConverter x:Key="dateConverter" />
    <mashup:DateConverter x:Key="dateConverterWithInfo" DateTimeFormatInfo="{x:Static m3:M3Format.DateTimeFormat}" />
    <mashup:DateConverter x:Key="dateConverterWithFormat" DateFormat="dd/MM/yyyy" />
    <m3:M3DateConverter x:Key="m3DateConverter" />
  </Grid.Resources>

  <StackPanel Margin="16">
    <DatePicker Name="datePicker" Width="200" Margin="0,0,0,8" HorizontalAlignment="Left" SelectedDate="2011/06/06" />

    <TextBlock Text="StringFormat only, no converter:" HorizontalAlignment="Left" FontWeight="Bold" />
    <TextBlock Text="{Binding ElementName=datePicker,Path=SelectedDate, StringFormat=d}" HorizontalAlignment="Left" />
    <TextBlock Text="{Binding ElementName=datePicker,Path=SelectedDate, StringFormat=D}" HorizontalAlignment="Left" />

    <TextBlock Text="DateConverter markup extension:" HorizontalAlignment="Left" FontWeight="Bold" />
    <TextBlock Text="{Binding ElementName=datePicker,Path=SelectedDate, Converter={mashup:DateConverter}}" HorizontalAlignment="Left" />
    <TextBlock Text="{Binding ElementName=datePicker,Path=SelectedDate, Converter={mashup:DateConverter}, ConverterParameter=D}" HorizontalAlignment="Left" />
    <TextBlock Text="{Binding ElementName=datePicker,Path=SelectedDate, Converter={mashup:DateConverter}, ConverterParameter=yyyy MM dd}" HorizontalAlignment="Left" />

    <TextBlock Text="DateConverter resource:" HorizontalAlignment="Left" FontWeight="Bold" />
    <TextBlock Text="{Binding ElementName=datePicker,Path=SelectedDate, Converter={StaticResource dateConverter}}" HorizontalAlignment="Left" />
    <TextBlock Text="{Binding ElementName=datePicker,Path=SelectedDate, Converter={StaticResource dateConverter}, ConverterParameter=D}" HorizontalAlignment="Left" />
    <TextBlock Text="{Binding ElementName=datePicker,Path=SelectedDate, Converter={StaticResource dateConverterWithInfo}}" HorizontalAlignment="Left" />
    <TextBlock Text="{Binding ElementName=datePicker,Path=SelectedDate, Converter={StaticResource dateConverterWithFormat}}" HorizontalAlignment="Left" />

    <TextBlock Text="M3DateConverter markup extension:" HorizontalAlignment="Left" FontWeight="Bold" />
    <TextBlock Text="{Binding ElementName=datePicker,Path=SelectedDate, Converter={m3:M3DateConverter}}" HorizontalAlignment="Left" />

    <TextBlock Text="M3DateConverter resource:" HorizontalAlignment="Left" FontWeight="Bold" />
    <TextBlock Text="{Binding ElementName=datePicker,Path=SelectedDate, Converter={m3:M3DateConverter}}" HorizontalAlignment="Left" />

    <TextBlock Text="M3DateFormat markup extension:" HorizontalAlignment="Left" FontWeight="Bold" />
    <TextBlock Text="{m3:M3DateFormat}" HorizontalAlignment="Left" />

    <TextBlock Text="TwoWay binding:" HorizontalAlignment="Left" FontWeight="Bold" />
    <TextBox Text="{Binding Mode=TwoWay, ElementName=datePicker,Path=SelectedDate, Converter={StaticResource m3DateConverter}}" HorizontalAlignment="Left" />

  </StackPanel>

</Grid>

I did not talk about event and event values in this post. If you pass doubles and dates you should make sure to select the type when configuring the event’s parameters in the designer. There is also a CurrentItemValue converter that can be very useful when binding to a current item in a mashup control. But that has more to do with binding than formatting.

Happy coding!

36 thoughts on “Formatting dates and numbers in a Mashup

  1. Joakim Bodin

    Thank you for the informative post!

    Is there a way to convert a date in the form of “20040825” to “25-08-2004” at this time?

    Thanks,

    Joakim

    Reply
  2. norpe

    The output format for that would be “dd-MM-yyyy” but I’m not sure where you would have a source date on the format “yyyyMMdd”. Do you have an example of where you want to do this?

    Reply
    1. Joakim Bodin

      I have a DataListPanel that is populated by a web service that fetches data from M3. One of the columns display date in the form of a numeric “yyyyMMdd”. I was hoping to convert that into a “dd-MM-yyyy” string to make it easier to read.

      I realize now that this probably isn’t what the date converters were intended to do. Do you perhaps know of any alternatives?

      Thank you for your time,

      Joakim

      Reply
      1. norpe

        In that case you would need to convert a double to a DateTime and then use StringFormat or a converter to format the DateTime to a date string. I have looked around but I can’t find any converter of ours or a standard converter that can do this.

        To solve these scenarios when the data types are incorrect we would need to add new converters or extend the existing converters to support more data types.

      2. Joakim Bodin

        Right now I’m looking at either manipulating the string in the SQL query already, or creating my own converter through the LSO SDK. I think I might even have access to a feature that already has a converter defined for this particular conversion.

        Thank you for your reply =)

        Joakim

  3. Heiko

    Hi Karin,
    my Mashup application reads a numeric value from a MI list panel, and the value is passed to a TextBox. The user can change the value, and then an update is executed using an MI panel.
    Prb: The numeric format in the TextBox is using a local decimal separator, in this case in Germany it is “comma”. The API expects a “dot”. I didn’t find a way to do this conversion.
    It is pure mashup, so I can’t write a custom converter. Is there any solution available ?

    Thank you in advance
    Heiko

    Reply
    1. karinpb Post author

      Hi,
      I would recommend you to use the NumericTextBox in Mango.UI.Controls. You can bind the same number format that M3 has. Example without bracets:
      ui:NumericTextBox Name="txNumeric" Text="{Binding Path=CurrentItem[PPQT], ElementName=MyList, Mode=OneWay}" NumberFormat="{x:Static m3:M3Format.NumberFormat}"
      The MIList will default return the number format that is on your PC. If you want the MIList to show the doubles in M3 format you can use MForms.Mashup.M3DoubleConverter in the list and then bind this value to your NumericTextBox. Working with binding instead of mashup events will keep the type of the data. When using Mashup events to set values everything is a string.

      Reply
      1. Hans

        Hi Karin;
        I’m so glad I found you post mentioning the NumericTextBox. When I try to use it I get the message (In the designer) “Cannot create an instance of “NumericTextBox”. Other controls in Mango.UI seems to work; SpinnerControl for example. On the other hand does StatusBar give the same error message as NumericTextBox. I am mapping to Mango.UI version 10.0.40000.1. Do I need to reference any other Mango assembly?

        Reagards
        Hans

      2. Martin

        Hi,

        I have the same problem as Heiko had/has.

        This solution don’t work:

        It shows up with a comma as decimal separator. I also tried the MIListPanel recommendation but the same result appears.

        When I paste the Mashup with all the number converters everything has comma as decimal separator. When i change the decimal separator to dot in MNS150, I get the same result in the above picture – it works. Is there something wrong when using a comma? When you try changing the values in the textboxes to a comma they appear with a red square.

        Regards Martin

  4. Martin Trydal Torp

    Hi,
    I’m trying to make an output value from an API convert into nn.dd(54.55) from the output nn,dddd(comma and several decimals). This is to make it possible to update the value with the update transaction without changing the format. I have tried the code:

    Can you guys think of a reason why the converter does not change the value in the TextBox. It worked perfect with the date.

    Reply
    1. karinpb Post author

      Hi,
      The code was lost from your comment. There are a number of reasons why conversions fail. The most common cases are that the output from the API is not a decimal but specified as a string. Check the metadata and the log at debug.

      Reply
      1. Heiko

        The real challenge is to take a numeric or date field from a “normal” M3 panel and pass it to an API. The input field type is defínetely “String”, and the seperator/s can be any, due to divisional settings in MNS100, indiviually overruled by user settings in MNS150. Now you have to pass it to an API with dot as seperator.

        Also a date format can be any, DMY, YMD, MDY, usually without separators. It sounds crazy, but what I did is to start an MDBREADMI query after “CurrentItemChanged” which gets the value directly from the database. Going this way you are also independent of the view, there is no risk any more that the user selects a sort order or view which doesn’t contain the fields you need. The further processing is then based on the MDBREADMI result.

        For API responses, I have found a solution – using the ConverterCulture definition will change the response to “dot” formatted by default, this value can be sent to another API (but of course you will loose the user’s local setting).

        Instead of …

        … try this:

        You can also use the textblock to set the number of decimals different to the API response by using a StringFormat definition:


        All this solutions require direct XAML editing.

      2. Martin

        Hi,
        If I cut this down to the core issue. If my MNS150 settings is set to comma as a decimal separator is there any way to convert the comma to a dot? Let’s say I have two textboxes next to each other where the one is binded to the other. Is it possible that the one textbox is showing 25,50(comma) and the other is showing 25.50(dot)? I can see it works when the MNS150 setting is set to dot as a decimal separator.

        //Martin

  5. Martin

    Hi Heiko,

    The code went missing from Your comment. Is it possible that you could send me Your(there is bug forcing the y to be a capital Y) XAML solution?. It would be very appreciated. Or if you can send the code that went missing. My e-mail is: martin.trydal.torp@vince.no

    Regards Martin

    Reply
    1. Didier CARA

      Hello,
      Thanks for your example.
      But I have a problem with the StringFormat in DataListPanel with SQL Webservice.

      For example I have a SQL webservice : Select OKCUNO,OKCUNM,OKRGDT FROM OCUSMA WHERE OKCONO = ?

      And in my mashup I have :

      And the OKRGDT column is empty, if I delete the StringFormat, the OKRGDT contains the date.

      I have tested with converter, some stringformat, but I not solved my problem.

      Any solutons ?

      Regards Didier

      Reply
  6. Heiko

    Hi, I suppose your Mashup code was eliminated … but I hope this helps:

    Add to your namespace:
    xmlns:m3=”clr-namespace:MForms.Mashup;assembly=MForms”

    Add a grid resource: (I have replaced the tags with Text, maybe that caused your problem)
    (tag)m3:M3DateConverter x:Key=”dateConverter”(endTag)

    And finally the column:
    (tag)GridViewColumn Header=”Date” DisplayMemberBinding=”{Binding xxxxxx, Converter={StaticResource dateConverter}}” (endTag) … where xxxxxx is the field name.

    That worked fine for me and my customer.

    /Heiko

    Reply
  7. viciniab

    Hello,

    I am wondering the same thing as Martin above. But I cannot find any asnwer.

    “Hi,
    If I cut this down to the core issue. If my MNS150 settings is set to comma as a decimal separator is there any way to convert the comma to a dot? Let’s say I have two textboxes next to each other where the one is binded to the other. Is it possible that the one textbox is showing 25,50(comma) and the other is showing 25.50(dot)? I can see it works when the MNS150 setting is set to dot as a decimal separator”

    Is there any solution for this?

    //Olof

    Reply
    1. Martin

      If you want the comma to be converted into a dot before sending it to the API, I’ve found a solution using the new functions expression. I can send you a solution if you want. I think this solution will work if you have two textboxes next to each other also(one with comma and one with dot). Regards Martin

      Reply
  8. gran

    Hi,

    I need to use checkbox (IsChecked) with M3 API. So I need to convert IsChecked (Boolean) to Int value.
    I search converter class but I don’t find this. I just find System.Convert with ToInt32 but I don’t know how to use because there is no constructor or factorymethod.

    Can you help me to make this please?

    Regards

    Reply
    1. norpe

      I could not find a way to do this in the existing Mashup framework without using custom C# code (an SDK feature).
      Two new converters will be available in the next hotfix for Smart Office (BoolToInConverter and IntToBoolConverter).

      <Grid xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ui="clr-namespace:Mango.UI.Controls;assembly=Mango.UI" xmlns:mashup="clr-namespace:Mango.UI.Services.Mashup;assembly=Mango.UI">
          <Grid.RowDefinitions>
              <RowDefinition Height="Auto" />
              <RowDefinition Height="Auto" />
              <RowDefinition Height="15" />
              <RowDefinition Height="Auto" />
              <RowDefinition Height="Auto" />
          </Grid.RowDefinitions>
          <Grid.ColumnDefinitions>
              <ColumnDefinition Width="1*" />
          </Grid.ColumnDefinitions>
          <CheckBox Grid.Row="0" Name="checkBoxTest" Content="Boolean to integer" />
          <TextBox Grid.Row="1" Name="textBoxText" Text="{Binding IsChecked, ElementName=checkBoxTest, Converter={mashup:BoolToIntConverter}}" />
          <ComboBox Grid.Row="3" Name="comboBoxTest2" SelectedIndex="0">
              <ComboBox.Items>
                  <ComboBoxItem>0</ComboBoxItem>
                  <ComboBoxItem>1</ComboBoxItem>
              </ComboBox.Items>
          </ComboBox>
          <CheckBox Grid.Row="4" Name="checkBoxTest2" Content="Integer to boolean" IsChecked="{Binding SelectedIndex, ElementName=comboBoxTest2, Converter={mashup:IntToBoolConverter}}" />
      </Grid>
      
      Reply
  9. Richard Eweg

    Hi, I’m looking for a way to retrieve the local time (on click) (in the PMS420 API) instead of the server time it picks by default (China – Uk has quite a big time difference). any ideas?

    Reply
    1. karinpb Post author

      Hi,
      I’m out of office with no access for a few weeks. I don’t know the API but you should pass the Date in the event. There should be a static way to get the current time but I don’t know it without checking so I have to get back to you or see if a college can answer.

      This is the static way to get the current date."{Binding Source={x:Static System:DateTime.Now"} But it will get the value when the mashup is rendered. Try and use it in an event. Perhaps you have to combine this with the setproperty event to get the current time when the button is clicked. It would be nice to have a fixed value for the current time in an event. Let me ask around:-)

      Edited: Use the function expressions approached as described in Function expressions in varible replacements. The Mashup example with the event triggered from a button with a parameter to the event can be used together with GetNow() and the ToString(DateTime, Format) function.

      Reply
      1. Richard Eweg

        Hi Karinpb, I was thinking the same, I know to pick the division based on the user, and i think there should be a way for this to. I’m not that familier with the statements and their syntax. I hope you’ll be able to find something; after my vacation I’ll take a further look at your static system date suggestion. Thanks

      2. karinpb Post author

        Hi Richard,
        I’m back at the office now.
        You can use variable replacements together with a formatting function that we have in Smart Office. Check Function expressions in variable replacements.
        For example this statement below will show you have you create a binding that will give you the time and then format it to HHmmss. In the blog post look at the Basic Mashup Example to see how to trigger and event from a button and pass in your local time as a parameter to the event from the buttom.

        The parameter should look like this considering that the time is a numeric 6 digit value:

        <mashup:Parameter SourceKey="Value" Value="{}{=ToString(GetNow(), 'HHmmss')}" /> 
  10. Eric

    Is there a converter class to be able to look for values greater than X.

    I am attempting to use a DataTrigger binding where I would like to set the enable flag on a button to either True or False depending on if the value is greater than one. I’ve attempted to do something like the following however this will lock my mashup. I would assume that I need to add a resource but don’t know where to find such a converter constructor.

    This data trigger is part of the style trigger of a button.

    I have also tried to bind the variable’s value with a greater than 1; however this will lock up the mashup

    I have looked in the Mango.UI.Utils Namespace and the MForms.Mashup namespace but I don’t find anything specific to greater than.

    Thanks as always.

    Reply
    1. Heiko

      Hi Eric,

      in a DataTrigger you can only compare “equal to”. But when you add a Mashup event to your button, you can define conditions for your event, and the event could can be executed based on conditions like “not equal”, “less than”, “greater than” etc, and you can use the event parameter to set a true/false target value which you can use for later comparisions. It adds a lot of code to your XAML, but it is possible.

      Reply
    2. karinpb Post author

      A bunch of Converters that corresponds to the Mashup Event conditions have been added in HF19 of Smart Office 10.2.1.

      Supported Mashup Value Types:
      DateTime, Numeric and String

      Comparison Converters:
      ComparisonEqualToBooleanConverter
      ComparisonNotEqualToBooleanConverter
      ComparisonLessThanToBooleanConverter
      ComparisonLessThanOrEqualToBooleanConverter
      ComparisonGreaterThanToBooleanConverter
      ComparisonGreaterThanOrEqualToBooleanConverter

      Reply
  11. karinpb Post author

    A converter would have been the easiest way. I’ve added an enhancement request to add all conditions that you can have in an event as a converters.

    The way to solve this would be to have an event react to for example current item change and then the event will set a property. How to set a property is shown in the Property setter example under Help in the Designer. How to disable a button with a conditional event is shown in https://smartofficeblog.com/2013/09/23/mashup-enable-a-button-based-on-status-and-currentitemchanged/

    The event does not have to be CurrentItemChanged, it can be any event.

    I spotted your company in your email. I love those products 🙂

    Reply
  12. Damian

    Hello. I love reading this as I am learning mashups, so thank you.

    is there a way to conditional format a status to show word instead of the number in a textblock? I am calling an API to get details, but it pulls back the status, and the user wants to see what that status actually means.

    if want the [REST] if 22, to say Orderline added or if 33 to say allocated or if 44 to say picking list and so on.

    any help would be greatly appreciated.

    Reply
    1. Richard Eweg

      Hi Damian, I think what you want can be achieved with conditional styles.
      When you open the settings of your (list)panel change the personalisation type to ‘inline’ this will make sure you can create your own unique personalisations that will be only visible in the mashup.
      go to start capture – ricght click on the applicable header and choose add conditional style.
      here you should create a rule that changes the text when a specific value is found in the target field.

      that’s basically it, you need to make a seperate rule for all different statuses.

      Reply

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s