Mashup – SQL Wildcard / DataGrid with sorting / Copy to Clipboard

Hi,

It’s been a while since I shared something now… I primary spent my time working with mashup combined with SQL… and when I first started there was no turning back.     The same about the DataGrid, its tooo powerful!

Today i’ll share one of probably many ways, how you can perform a wildcard search from a mashup.  I’ll also drop you a few tips when using the DataGrid regarding copying and sorting.

– SQL – WildCard

This solution I provide here now, should give pretty much the exact same results as searching with standard M3.

The use provides an input to a TextBox.

You need to add the following to your mashup to be able to use the IsNotNullOrEmptyConverter

xmlns:utils=”clr-namespace:Mango.UI.Utils;assembly=Mango.UI”

We then use a DataTrigger to provide us a default value if the TextBox is blank, in this case the % to be used in the SQL LIKE(‘%’)  NB: This is a hidden TextBox

<TextBox Name="ItemWhsCheck" Visibility="Hidden">
     			  <TextBox.Style>
      			 <Style x:Key="ItemWhsCheck" TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
         			 <Setter Property="Text" Value="{Binding ElementName=ItemWhs, Path=SelectedValue}" />
	        			  <Style.Triggers>
	            		 	<MultiDataTrigger>
	               		 	<MultiDataTrigger.Conditions>
	                   			<Condition Binding="{Binding ElementName=ItemWhs, Path=SelectedValue, Converter={StaticResource IsNotNullOrEmptyConverter}}" Value="False" />
	                			</MultiDataTrigger.Conditions>
	                			<Setter Property="Text" Value="%" />
	            			</MultiDataTrigger>
         		 		</Style.Triggers>
      				 </Style>
    				</TextBox.Style>
  </TextBox>

We should then be able to bind the correct values to the provide it to the SQL.

	<mashup:Parameter TargetKey="ListItems1.MLWHLO" Value="{Binding ElementName=ItemWhsCheck, Path=Text}" />

In the LWS Designer the “?” will be the Input from the mashup.

SELECT MMITNO,MMFUDS from MITMAS  WHERE MMCONO=1  AND TRIM(MMFUDS) LIKE REPLACE(CAST( ? AS VARCHAR(1000)), ‘*’, ‘%’)

This will perform a search which allows exact hits, or multiple hits and the use of multiple wildcards.

Search: O-RING*  Search: O-RING, BS-204 VITON 90  Search- O-RING*204*90

All will provide the following result.  Result: O-RING, BS-204 VITON 90

You can also combine multiple of these.

AND TRIM(MMFUDS) LIKE REPLACE(CAST( ? AS VARCHAR(1000)), ‘*’, ‘%’)  AND TRIM(MMITNO) LIKE REPLACE(CAST( ? AS VARCHAR(1000)), ‘*’, ‘%’)  AND MMITTY LIKE(CAST( ? AS VARCHAR(1000)))  AND TRIM(LISERN) LIKE REPLACE(CAST( ? AS VARCHAR(1000)), ‘*’, ‘%’)  AND MLWHLO LIKE(CAST( ? AS VARCHAR(1000)))  AND TRIM(MLWHSL) LIKE REPLACE(CAST( ? AS VARCHAR(1000)), ‘*’, ‘%’)  AND MLCAMU LIKE(CAST( ? AS VARCHAR(1000)))

DataGrid – Copy to Clipboard

In this example I’m adding a ContextMenu to the DataGrid to allow to copy the line infomration to mail/excel, but you could just aswell use a button .  I added th following extra properties:

The SelectionMode is set to Exteded to allow multiple selections .  The ClipBoardCopyMode is set to IncludeHeaders

<DataGrid Name="dataGrid1" ItemsSource="{Binding ResultSetCollection}" Style="{DynamicResource styleDataGrid}" SelectionMode="Extended" ClipboardCopyMode="IncludeHeader" AutoGenerateColumns="False" SelectedIndex="0" Visibility="{Binding ElementName=SerialRadio, Path=IsChecked, Converter={StaticResource BooleanToVisibilityConverter}}">
			<DataGrid.ContextMenu>
				<ContextMenu>
					<MenuItem Header="Copy to clipboard" Command="ApplicationCommands.Copy" CommandTarget="{Binding ElementName=dataGrid1}" />
				</ContextMenu>
			</DataGrid.ContextMenu>

You should now be able to use the Copy to Clipboard, if using the standard DataGridTextColumns

However, if you would like to use the DataGridTemplateColumn you need to add ClipboardContentBinding or you will be copying blank values.

When using the DataGridTempalte, you also will be losing the standard sorting options, unless you add CanUserSort and SortMemberPath.

The function of this TemplateColumn is just to colour the text red if the overdue value = 1


<DataGridTemplateColumn Header="Next test date" CanUserSort="True" SortMemberPath="NEXTDATE" ClipboardContentBinding="{Binding NEXTDATE}">
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<StackPanel Orientation="Horizontal">
								<TextBlock MinWidth="80" MaxWidth="0" Text="{Binding NEXTDATE}">
									<TextBlock.Style>
										<Style TargetType="{x:Type TextBlock}" BasedOn="{StaticResource {x:Type TextBlock}}">
											<Style.Triggers>
												<MultiDataTrigger>
													<MultiDataTrigger.Conditions>
														<Condition Binding="{Binding Overdue}" Value="1" />
													</MultiDataTrigger.Conditions>
													<Setter Property="Background" Value="Red" />
													<Setter Property="Text" Value="{Binding NEXTDATE}" />
												</MultiDataTrigger>
											</Style.Triggers>
										</Style>
									</TextBlock.Style>
								</TextBlock>
							</StackPanel>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>
<DataGridTextColumn Header="Service" Binding="{Binding NEXTSERVICE}" />

This is not the full .xaml ….  But it should contain alot of ideas  I hope its worth sharing.

Here is an example of an end result, and the speed is amazing.

ItemSearch

Please take contact if you got any questions, or are willing to share some of your own ideas.
And I also need to thank Heiko for providing solutions when everything looks dark! 🙂

And since I haven’t seen many M3 SQL’s out there…. Here is a copy of the one behind this mashup, i’m no proffessional, so there might be minor errors.

select MMCONO,MMITNO,MMFUDS,MMITTY,LISERN,MLWHLO,MLWHSL,MLCAMU,MMITGR,LISTAT,
(Select A.MPPOPN from MITPOP A where A.MPCONO=1 and A.MPALWT=’4′ AND A.MPITNO=MMITNO fetch first 1 row only) as Partno,
(Select Case When Count(mlbano) > ‘0’ Then ‘*’ Else ” end from mitloc where mlcono=1 and mlcamu=lisern) as CONTAINED,
(Select Case When Count(asnhsn) > ‘0’ Then ‘*’ Else ” end from MROABS where ascono=1 and (asitno=mmitno and assern=lisern) OR (asnhai=mmitno and asnhsn=lisern )) as ATTACHED,

CASE
WHEN QOSTDT is null Then
CASE
WHEN HP.QHSTDT is null THEN NULL
ELSE HP.QHSTDT
END
ELSE
CASE
WHEN HP.QHSTDT is null THEN QOSTDT
ELSE
CASE
WHEN QOSTDT HP.QHSTDT Then HP.QHSTDT
END
END
END as NEXTDATE,

CASE
WHEN QOSTDT is null Then
CASE
WHEN HP.QHSTDT is null THEN NULL
ELSE HP.QHSUFI
END
ELSE
CASE
WHEN HP.QHSTDT is null THEN QOSUFI
ELSE
CASE
WHEN QOSTDT HP.QHSTDT Then HP.QHSUFI
END
END
END as NEXTSERVICE,

CASE
WHEN (days(current date ) > days (to_date(char(QOSTDT),’yyyymmdd’)))
THEN ‘1’
WHEN (days(current date ) > days (to_date(char(QHSTDT),’yyyymmdd’)))
THEN ‘1’
END AS “Overdue”,

(SELECT
CASE WHEN C.MLCAMU ” THEN C.MLWHLO
ELSE C.MLWHLO
END
FROM MITLOC C WHERE C.MLCONO=1 AND A.MLWHLO IN(‘191′,’291’) AND A.MLCAMU=C.MLBANO ) as ContWhs,

(SELECT
CASE WHEN B.MLCAMU ” THEN B.MLCAMU
ELSE B.MLWHSL
END
FROM MITLOC B WHERE B.MLCONO=1 AND A.MLWHLO IN(‘191′,’291′) AND A.MLCAMU=B.MLBANO ) as ContLoc

FROM
MITMAS
JOIN MILOIN ON LICONO=1 AND LIITNO=MMITNO
JOIN MITLOC A ON MLCONO=1 and LIITNO=MLITNO and LISERN=MLBANO
LEFT JOIN MWOPLP ON QOCONO = MLCONO AND QOFACI=’100’ AND QOPRNO = MLITNO AND QOBANO = MLBANO AND QOORTY = ‘SMA’ AND QOPSTS < 59
AND QOSTDT =(SELECT MIN(MP2.QOSTDT) FROM MWOPLP MP2 WHERE MP2.QOCONO = MLCONO AND MP2.QOFACI='100' AND MP2.QOPRNO = MLITNO AND MP2.QOBANO = MLBANO AND MP2.QOORTY = 'SMA' AND MP2.QOPSTS < 59)
LEFT JOIN MMOHED HP ON HP.QHCONO = MLCONO AND QHFACI='100' AND HP.QHPRNO = MLITNO AND HP.QHBANO = MLBANO AND HP.QHORTY = 'SMA' AND HP.QHWHST < 90
AND HP.QHSTDT =(SELECT MIN(HP2.QHSTDT) FROM MMOHED HP2 WHERE HP2.QHCONO = MMCONO AND HP2.QHFACI='100' AND HP2.QHPRNO = MLITNO AND HP2.QHBANO = MLBANO AND HP2.QHWHST < 90)

WHERE MMCONO=1
AND TRIM(MMFUDS) LIKE REPLACE(CAST( ? AS VARCHAR(1000)), '*', '%')
AND TRIM(MMITNO) LIKE REPLACE(CAST( ? AS VARCHAR(1000)), '*', '%')
AND MMITTY LIKE(CAST( ? AS VARCHAR(1000)))
AND TRIM(LISERN) LIKE REPLACE(CAST( ? AS VARCHAR(1000)), '*', '%')
AND MLWHLO LIKE(CAST( ? AS VARCHAR(1000)))
AND TRIM(MLWHSL) LIKE REPLACE(CAST( ? AS VARCHAR(1000)), '*', '%')
AND MLCAMU LIKE(CAST( ? AS VARCHAR(1000)))

Fetch first 500 rows only

Thanks.

Regards

Ken Eric

Mashup – Dialog Window , Timer and DataListPanel

Since I just posted about the dialog box and the timer to catch the value.
It makes sense to do a small third post mixing it all together with a DataListPanel in a Dialog window.
Again, there was problem starting the DataListPanel with values in the DialogBox. But solved the same way as previous.

Link to Timer: Using the timer .

Link to Dialog: Creating a Dialog Window.

The layout here is not very sexy as it’s still under construction, but it’s an idea worth sharing.
The whole point is to be able to add extra lines to the purchase orders based on calculations done in the background with SQL from Web Service, and start the DataListPanel on startup in a new Dialog Window.

Reorder

This is not a complete working xaml file, but part of the Dialog window containing the DataListPanel

<Grid Height="700" Width="1200" 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:clr="clr-namespace:System;assembly=mscorlib" xmlns:Services="clr-namespace:Mango.Services;assembly=Mango.Core" xmlns:ps="clr-namespace:PF.Client.Mashup;assembly=PF.Client">
	<Grid.Resources>
		<mashup:CurrentItemValue x:Key="CurrentItemValue" />
		<clr:String x:Key="BaseUri">{mashup:ProfileValue Path=M3/WebService/url}"</clr:String>
	</Grid.Resources>
	<Grid.ColumnDefinitions>
		<ColumnDefinition Width="1*" />
	</Grid.ColumnDefinitions>
	<Grid.RowDefinitions>
		<RowDefinition Height="50" />
		<RowDefinition Height="500" />
		<RowDefinition Height="50" />
	</Grid.RowDefinitions>

	<StackPanel Orientation="Vertical" Grid.Row="0">
		<mashup:Dialog Name="MyDialog" Uri="DialogAddPO.xaml" Grid.Column="0" Grid.Row="0">
		</mashup:Dialog>
		<TextBox Name="SupplierNumber" Grid.Row="0" Grid.Column="3" MinWidth="115" MinHeight="20" MaxWidth="115" MaxHeight="50" HorizontalAlignment="Left" MaxLength="18" Text="{Binding Converter={StaticResource CurrentItemValue}, ConverterParameter=Result, Mode=OneTime}" IsEnabled="False" />
		<TextBox Name="PONumber" Grid.Row="0" Grid.Column="3" MinWidth="115" MinHeight="20" MaxWidth="115" MaxHeight="50" HorizontalAlignment="Left" MaxLength="18" Text="{Binding Converter={StaticResource CurrentItemValue}, ConverterParameter=PONumber, Mode=OneWay}" IsEnabled="False" />
	</StackPanel>

	<!-- Timer to catch the SupplierNumber value andprovide it to the DataListPanel -->
	<ps:TriggerPanel Name="SQLReorderTrigger" IsDataAreaInSession="False" IsAsynchronous="True" IsAutoLayoutEnabled="True" IsConversionEnabled="True" IsResponseValidationEnabled="False">
		<ps:TriggerPanel.Events>
			<mashup:Events>
				<mashup:Event TargetName="SQLTriggerTimer" SourceEventName="Startup" TargetEventName="Start" />
			</mashup:Events>
		</ps:TriggerPanel.Events>
	</ps:TriggerPanel>

	<mashup:Timer Name="SQLTriggerTimer" Interval="0:0:01" ElapsedCount="1" Count="1" MinInterval="0:0:01" />

	<!-- Hidden TextBlock to get the CurrentSystem. Dynamic for PRD/TST/DEV/MIG -->
<TextBlock Name="ProfileName" DataContext="{x:Static Services:ApplicationServices.SystemProfile}" Text="{Binding Name}" Grid.Row="0" Visibility="Hidden" />

	<mashup:DataListPanel Name="SQLReorderPointPanel" Grid.Row="1">
		<mashup:DataListPanel.Events>
			<mashup:Events>
				<mashup:Event SourceEventName="Elapsed" TargetName="SQLReorderPointPanel" TargetEventName="Read" Debug="True" SourceName="SQLTriggerTimer">
					<mashup:Parameter TargetKey="BaseUri" Value="{mashup:ProfileValue Path=M3/WebService/url}" />
					<mashup:Parameter TargetKey="Profile" Value="{Binding ElementName=ProfileName, Path=Text}" />
					<mashup:Parameter TargetKey="WS.Wsdl" Value="{}{BaseUri}/LWSSQL{}{Profile}/SQL_Reorderpoint?wsdl" />
					<mashup:Parameter TargetKey="WS.Address" Value="{}{BaseUri}/LWSSQL{}{Profile}/SQL_Reorderpoint" />
					<mashup:Parameter TargetKey="WS.MaxReceivedMessageSize" Value="2000000" />
				</mashup:Event>
			</mashup:Events>
		</mashup:DataListPanel.Events>
		<mashup:DataListPanel.DataService>
			<mashup:DataService Type="WS">
				<mashup:DataService.Operations>
					<mashup:DataOperation Name="Read">
						<mashup:DataParameter Key="WS.CredentialSource" Value="Current" />
						<mashup:DataParameter Key="WS.Operation" Value="GetList" />
						<mashup:DataParameter Key="WS.Contract" Value="SQL_Reorderpoint" />
					</mashup:DataOperation>
				</mashup:DataService.Operations>
			</mashup:DataService>
		</mashup:DataListPanel.DataService>

		<DataGrid Name="Reorder" ItemsSource="{Binding ResultSetCollection, Mode=OneWay}" Grid.Row="1" Style="{DynamicResource styleDataGrid}" CanUserDeleteRows="True" SelectionMode="Single" SelectedIndex="0" AutoGenerateColumns="False">
			<DataGrid.Columns>
				<DataGridTextColumn Header="Item" Binding="{Binding MBITNO}" />
				<DataGridTextColumn Header="Description" Binding="{Binding MMFUDS}" />
				<DataGridTextColumn Header="Min" Binding="{Binding MBREOP, StringFormat=f0}" />
				<DataGridTextColumn Header="Max" Binding="{Binding MBMXST, StringFormat=f0}" />
				<DataGridTextColumn Header="Usage" Binding="{Binding MBUSYE, StringFormat=f0}" />
				<DataGridTextColumn Header="On-Hand" Binding="{Binding MBAVAL, StringFormat=f0}" />
				<DataGridTextColumn Header="In Order" Binding="{Binding MBORQT, StringFormat=f0}" />
				<DataGridTextColumn Header="Lead Time" Binding="{Binding MBLEA1, StringFormat=f0}" />
				<DataGridTextColumn Header="Supplier" Binding="{Binding IDSUNM}" />

				<DataGridTemplateColumn Header="Qty">
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<StackPanel Orientation="Vertical">
								<TextBox Text="0" MinWidth="50" MaxLength="5" MaxWidth="50" />
							</StackPanel>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>

				<DataGridTemplateColumn Header="Add to PO">
					<DataGridTemplateColumn.CellTemplate>
						<DataTemplate>
							<StackPanel Orientation="Horizontal">
									<TextBlock Name="ProfileName2" DataContext="{x:Static Services:ApplicationServices.SystemProfile}" Text="{Binding Name}" Visibility="Hidden" />
									<Button Name="AddReorderLine" Content="Add" VerticalAlignment="Top">
									<Button.CommandParameter>
										<mashup:Events>
											<mashup:Event SourceEventName="Click" TargetName="WSReorderAddLine" TargetEventName="Read" Debug="True">
												<mashup:Parameter TargetKey="BaseUri" Value="{mashup:ProfileValue Path=M3/WebService/url}" />
												<mashup:Parameter TargetKey="Profile" Value="{Binding ElementName=ProfileName2, Path=Text}" />
												<mashup:Parameter TargetKey="WS.Wsdl" Value="{}{BaseUri}/lws_{}{Profile}/PPS200_AddLine?wsdl" />
												<mashup:Parameter TargetKey="WS.Address" Value="{}{BaseUri}/lws_{}{Profile}/PPS200_AddLine" />
												<mashup:Parameter TargetKey="WS.MaxReceivedMessageSize" Value="2000000" />
											</mashup:Event>
										</mashup:Events>
									</Button.CommandParameter>
								</Button>
							</StackPanel>
						</DataTemplate>
					</DataGridTemplateColumn.CellTemplate>
				</DataGridTemplateColumn>
			</DataGrid.Columns>
		</DataGrid>
	</mashup:DataListPanel>

	<mashup:DataPanel Name="WSReorderAddLine">
		<mashup:DataPanel.DataService>
			<mashup:DataService Type="WS">
				<mashup:DataService.Operations>
					<mashup:DataOperation Name="Read">
						<mashup:DataParameter Key="WS.Operation" Value="PPS200_AddLine" />
						<mashup:DataParameter Key="WS.Contract" Value="PPS200_AddLine" />
						<mashup:DataParameter Key="WS.CredentialSource" Value="Current" />
					</mashup:DataOperation>
				</mashup:DataService.Operations>
			</mashup:DataService>
		</mashup:DataPanel.DataService>
	</mashup:DataPanel>

	<StackPanel Grid.Row="3">
		<Button Content="Close">
		<Button.CommandParameter>
			<mashup:Events>
				<mashup:Event SourceEventName="Click" TargetEventName="Close">
				<mashup:Parameter TargetKey="Result" Value="{Binding ElementName=ProfileName, Path=Text}" />
				</mashup:Event>
			</mashup:Events>
		</Button.CommandParameter>
	</Button>
	</StackPanel>
</Grid>

Regards
Ken Eric

Mashup – Adding security to part of the mashup based on CurrentUser

I’ve seen a previously posts describing how to put security on a whole mashup.
But what if it is a mashup designed for all end-users, but part of it should be for limited users only, when using MI/Data Panels?

I will provide an example where I disable a GroupBox based on the CurrentUser access to MMS001 from SES401.

The first problem I ran into, was that there was missing an MI transaction to retrieve the user access, or at least I couldn’t find one.
So I create a new transaction in MDBREADMI, from CMNPUS to get the ALO field to get the values.

Input:
GetCMNPUS00

Output:
GetCMNPUS00Output

The next problem I had was that I had to run the MI transaction for user validation’ immediately’ on startup.
However, I couldn’t get the binding correct. It was like the MI startup event was triggered before I was able to bind the currentuser.
( There might be other ways to do this, it might just be me having problems with this kind of binding)
My work around for this was adding in a timer with a second delay. Which allowed me to run the MI Panel with the UserName.

I used a TriggerPanel on the startup which started the timer. The MIPanel was then triggered by Elapsed time after a second.
And then I had all the information required. Using a Hidden TextBox with a style.trigger to catch the UserAccess value ([ALO]).
Then I could bind the the text property directly to the GroupBox IsEnabled.

Here is an snapshot of the .xaml attached. 

UserAccessExample1

Here is a snapshot where I use this in the real world, where you see everything is disabled. 

 Example2UserAcccess

Attached is a full working source code. ( You have to create the MDBREADMI transaction first)

<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:ps="clr-namespace:PF.Client.Mashup;assembly=PF.Client" xmlns:m3="clr-namespace:MForms.Mashup;assembly=MForms" xmlns:Services="clr-namespace:Mango.Services;assembly=Mango.Core">
	<Grid.Resources>
	</Grid.Resources>

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

		<RowDefinition Height="Auto" />
	</Grid.RowDefinitions>

<!-- Startup Event -->
	<ps:TriggerPanel Name="ItemMasterUserNameTrigger">
		<ps:TriggerPanel.Events>
			<mashup:Events>
				<mashup:Event TargetName="ItemMasterUserNameTimer" SourceEventName="Startup" TargetEventName="Start" />
			</mashup:Events>
		</ps:TriggerPanel.Events>
	</ps:TriggerPanel>

	<mashup:Timer Name="ItemMasterUserNameTimer" Interval="0:0:01" ElapsedCount="1" Count="1" MinInterval="0:0:01" />

<!-- Hidden TextBlock to get UserName -->
	<TextBlock Name="ItemMasterUserName" DataContext="{x:Static Services:ApplicationServices.UserContext}" Text="{Binding UserName}" Visibility="Hidden" />

	<m3:MIPanel Name="ItemMasterDataReadOnlyMI">
		<m3:MIPanel.Events>
			<mashup:Events>
				<mashup:Event TargetName="ItemMasterDataReadOnlyMI" TargetEventName="Get" SourceEventName="Elapsed" SourceName="ItemMasterUserNameTimer">
					<mashup:Parameter TargetKey="USID" Value="{Binding ElementName=ItemMasterUserName, Path=Text}" />
					<mashup:Parameter TargetKey="DIVI" Value="{mashup:UserContextValue Path=M3/Division}" />
					<mashup:Parameter TargetKey="PGNM" Value="MMS001" />
				</mashup:Event>
			</mashup:Events>
		</m3:MIPanel.Events>
		<m3:MIPanel.DataSource>
			<m3:MIDataSource Program="MDBREADMI" Transaction="GetCMNPUS00" Type="Get" InputFields="USID,DIVI,PGNM" OutputFields="ALO" MaxReturnedRecords="1" />
		</m3:MIPanel.DataSource>
	</m3:MIPanel>

<!-- Validation check, disabled by default  -->
	<TextBox Name="ItemUserValid" Visibility="Hidden">
		<TextBox.Style>
			<Style x:Key="UserCheck" TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
				<Setter Property="Text" Value="False" />
				<Style.Triggers>
					<MultiDataTrigger>
						<Setter Property="Text" Value="False" />
					</MultiDataTrigger>
					<MultiDataTrigger>
						<MultiDataTrigger.Conditions>
							<Condition Binding="{Binding ElementName=ItemMasterDataReadOnlyMI, Path=[ALO]}" Value="111111111" />
						</MultiDataTrigger.Conditions>
						<Setter Property="Text" Value="True" />
					</MultiDataTrigger>
				</Style.Triggers>
			</Style>
		</TextBox.Style>
	</TextBox>

<!--  Setting the GroupBox Enabled or Disabled based on the CurrentUser acccess to MMS001 -->
	<GroupBox Name="GroupBox" Header="Validation" Style="{DynamicResource styleGroupLineMashup}" IsEnabled="{Binding ElementName=ItemUserValid, Path=Text}" Grid.Row="0">
		<Grid Margin="0,0,0,8">
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="100" />
				<ColumnDefinition Width="110" />
			</Grid.ColumnDefinitions>
			<Grid.RowDefinitions>
				<RowDefinition Height="32" />
				<RowDefinition Height="32" />
			</Grid.RowDefinitions>

			<Button Name="Button" Content="Button" Grid.Column="0" Grid.Row="0" />
			<Label Content="IsEnabled" Grid.Row="1" Grid.Column="0" />
			<TextBox Text="{Binding ElementName=ItemUserValid, Path=Text}" Grid.Row="1" Grid.Column="1" MinWidth="100" MaxWidth="100" />

		</Grid>
	</GroupBox>

	<GroupBox Name="GroupBox2" Header="No Validation" Style="{DynamicResource styleGroupLineMashup}" Grid.Row="1">
		<Grid Margin="0,0,0,8">
			<Grid.ColumnDefinitions>
				<ColumnDefinition Width="100" />
				<ColumnDefinition Width="110" />
			</Grid.ColumnDefinitions>
			<Grid.RowDefinitions>
				<RowDefinition Height="32" />
				<RowDefinition Height="32" />
			</Grid.RowDefinitions>

			<Button Content="Button" Grid.Column="0" Grid.Row="0" />
			<Label Content="IsEnabled" Grid.Row="1" Grid.Column="0" />
			<TextBox Name="TextBox" Text="Test 1" Grid.Row="1" Grid.Column="1" MinWidth="100" MaxWidth="100" />

		</Grid>
	</GroupBox>
	<ui:StatusBar Name="StatusBar" Grid.Row="1" Grid.Column="0" />
</Grid>

Regards
Ken Eric

Mashup – The “new modal Dialog window”

Previously this year I wrote a post regarding popups.  And now there is something so much better…
What I didn’t know then, was that there already existed a modal dialog window for exactly this kind of behaviour I wanted within the mashup in later release.
We recently had an upgrade of our environment, and there I suddenly was… Maybe it’s just me not keeping up with all the new features, and I guess there are others of you out there who also don’ know.
So I’d like to share a small example. You can also find an example in the mashup designer under common controls, if you have it.

What I find really nice, is that the dialog windows are own .xaml files, which means it’s being added really quickly if I have to re-use it somewhere else.

This is how it can look, in this case I used it for supplier search, which often can be good to have many places. It writes back from the Dialog.xaml to the primary.xaml.

SupplierDialogBox2

Below is the code that had to be added in the primary mashup. I also added a ‘F4” gesture to open it.


<StackPanel Grid.Row="1" Grid.Column="3">
                  <mashup:Dialog Name="SupplierMyDialog" Uri="SupplierDialogBox.xaml" WindowHeight="600" WindowWidth="540" HorizontalAlignment="Left" />
                  <TextBox Name="Supplier" Text="{Binding ElementName=SupplierMyDialog, Path=CurrentItem[Supplier]}" MinWidth="80" MaxWidth="80">
                     <TextBox.InputBindings>           
                        <KeyBinding Key="F4" Command="mashup:MashupInstance.MashupCommand">          
                           <KeyBinding.CommandParameter>             
                              <mashup:Events>
                                 <mashup:Event SourceEventName="Click" TargetName="SupplierMyDialog" Debug="True">
                                    <mashup:Parameter TargetKey="SupplierNumber" Value="{Binding ElementName=Supplier, Path=Text}" />
                                 </mashup:Event>
                              </mashup:Events>          
                           </KeyBinding.CommandParameter>       
                        </KeyBinding>  
                     </TextBox.InputBindings> 
                  </TextBox>   
  </StackPanel>

And here is the complete code for the DialogBox itself.  The close button will target the supplier field with the text input.

Grid Height="600" Width="540" 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:clr="clr-namespace:System;assembly=mscorlib" xmlns:Services="clr-namespace:Mango.Services;assembly=Mango.Core" xmlns:ps="clr-namespace:PF.Client.Mashup;assembly=PF.Client">
   <Grid.Resources>
      <mashup:CurrentItemValue x:Key="CurrentItemValue" />
   </Grid.Resources>

   <Grid.ColumnDefinitions>
      <ColumnDefinition Width="540" />
   </Grid.ColumnDefinitions>
   <Grid.RowDefinitions>
      <RowDefinition Height="80" />
      <RowDefinition Height="400" />
      <RowDefinition Height="50" />
      <RowDefinition Height="Auto" />
   </Grid.RowDefinitions>

   <GroupBox Style="{DynamicResource styleGroupLineMashup}">
      <Grid Margin="0,0,0,8">
         <Grid.ColumnDefinitions>
            <ColumnDefinition Width="60" />
            <ColumnDefinition Width="150" />
            <ColumnDefinition Width="80" />
         </Grid.ColumnDefinitions>
         <Grid.RowDefinitions>
            <RowDefinition Height="32" />
         </Grid.RowDefinitions>

         <TextBlock Text="Supplier:" Grid.Column="0" />
         <StackPanel Orientation="Vertical" Grid.Row="0" Grid.Column="1">
            <mashup:Dialog Name="SupplierMyDialog" Uri="SupplierDialogBox.xaml" Grid.Column="0" Grid.Row="0">
               </mashup:Dialog>         
            <TextBox Name="SupplierNumber" MinWidth="120" MaxWidth="120" HorizontalAlignment="Left" MaxLength="18" Text="" />

         </StackPanel>

         <Button Name="Button" Grid.Column="2" Content="Search">
            <Button.CommandParameter>
               <mashup:Events>
                  <mashup:Event TargetName="ItemMasterSupplierListBrowse" SourceEventName="Click" TargetEventName="Search" Debug="True">
                     <mashup:Parameter TargetKey="Query" Value="{Binding Path=Text, ElementName=SupplierNumber}" />
                  </mashup:Event>
               </mashup:Events>
            </Button.CommandParameter>
         </Button>
      </Grid>
   </GroupBox>

   <m3:ListPanel Name="ItemMasterSupplierListBrowse" Grid.Row="1" EnablePositionFields="False" EnableSortingOrder="False">
      <m3:ListPanel.Events>
         <mashup:Events>
            <mashup:Event SourceEventName="Startup">
               <mashup:Parameter TargetKey="IDCONO" />
               <mashup:Parameter TargetKey="IDSUNO" />
            </mashup:Event>

            <mashup:Event SourceName="ItemMasterSupplierListBrowse" SourceEventName="CurrentItemChanged" Target="{mashup:SetProperty ElementName=SupplierNumber, Path=Text}" Debug="True">
               <mashup:Parameter SourceKey="SUNO" TargetKey="Value" />
            </mashup:Event>
         </mashup:Events>
      </m3:ListPanel.Events>
      <m3:ListPanel.Bookmark>
         <m3:Bookmark Program="CRS620" Table="CIDMAS" KeyNames="IDCONO,IDSUNO" SortingOrder="1" IncludeStartPanel="True" />
      </m3:ListPanel.Bookmark>
   </m3:ListPanel>

   <Button Content="Close" Grid.Row="2">
      <Button.CommandParameter>
         <mashup:Events>
            <mashup:Event SourceEventName="Click" TargetEventName="Close">
               <mashup:Parameter TargetKey="Supplier" Value="{Binding ElementName=SupplierNumber, Path=Text}" />
            </mashup:Event>
         </mashup:Events>
      </Button.CommandParameter>
   </Button>
   
   <ui:StatusBar Name="StatusBar" Grid.Row="3" Grid.Column="0" />
</Grid>

Hope it can be to any help.

Regards
Ken Eric

 

Mashup/LES – Related search and changing view while searching.

I accidently discovered a while back that I could use the TargetKey to set views and sorting orders.
This was followed up by another small indecent, which led to another discovery.
Did you know that you are able change the view after a LES search has been performed and keep the current hits?
I will also share how you can perform a related search with LES from a mashup. ( I will not share how to do all the setup, it’s primary just getting the query right)
When combing all these, I believe you can create quite a powerful tool.

Setting the sorting order:

Very simple, but for some unknown.  Just use the TargetKey to set the value.

<mashup:Event TargetName=”MMS200″ SourceEventName=”Click” TargetEventName=”Apply”>
<mashup:Parameter TargetKey=”WWQTTP” Value=”5″ />
</mashup:Event>

Changing the view can be done in multiple ways, here is an example where it’s done from a ComboBox.

<ComboBox Name="ItemMasterChangeView" MinWidth="85" MinHeight="20" MaxWidth="85" MaxHeight="70" Margin="5">
             <mashup:Event.SelectionChanged>
                <mashup:Events>
                   <mashup:Event SourceEventName="SelectionChanged" TargetName="MMS200" TargetEventName="Apply">
                      <mashup:Event.Conditions>
                         <mashup:Conditions>
                            <mashup:Condition TargetKey="Value" SourceValue="{Binding ElementName=ItemMasterChangeView, Path=SelectedIndex}" TargetValue="1" Operator="Equal" />
                         </mashup:Conditions>
                      </mashup:Event.Conditions>
                      <mashup:Parameter TargetKey="WWFACI" Value="100" />
                      <mashup:Parameter TargetKey="WWWHLO" Value="100" />
                      <mashup:Parameter TargetKey="WOPAVR" Value="{Binding ElementName=ONHAND, Path=Content}" />
                   </mashup:Event>

                   <mashup:Event SourceEventName="SelectionChanged" TargetName="MMS200" TargetEventName="Apply">
                      <mashup:Event.Conditions>
                         <mashup:Conditions>
                            <mashup:Condition TargetKey="Value" SourceValue="{Binding ElementName=ItemMasterChangeView, Path=SelectedIndex}" TargetValue="2" Operator="Equal" />
                         </mashup:Conditions>
                      </mashup:Event.Conditions>
                      <mashup:Parameter TargetKey="WWFACI" Value="100" />
                      <mashup:Parameter TargetKey="WWWHLO" Value="100" />
                      <mashup:Parameter TargetKey="WOPAVR" Value="{Binding ElementName=WHS, Path=Content}" />
                   </mashup:Event>
                </mashup:Events>
             </mashup:Event.SelectionChanged>

             <ComboBoxItem Name="BLANK" Content="" />
             <ComboBoxItem Name="ONHAND" Content="ONHAND" />
             <ComboBoxItem Name="WHS" Content="WHS" />
          </ComboBox>

NOTE: CHANGING SORTING ORDER OR VIEW MIGHT GIVE YOU A FATAL ERROR IN SOME OF THE PREVIOUS VERSIONS OF M3.
I don’t know which version the fix came in, but we recently had a upgrade of our environment and it now runs without problem, so far.
However, if you receive an error message, try setting the sorting order with filter 1 or higher, for some strange reason it only used to crash if the filter was set to 0.

Related search – creating the string.

There might be other ways to do this, so if you solved this previously in any other way I hope you are willing to share.
I will show you two different ways you can concatenate text to get the string you need.

1. Provide input to RespText, and using the MultiBinding will get yourself a string looking like this:
related:[ITEM_RESP(“input”)]:

<TextBox Name="RespText"  Text=""   />
<TextBox Name="RespDummy1" Text="related:[ITEM_RESP(&quot;"  Visibility="Hidden" />
  <TextBox Name="RespDummy2" Text="&quot;)]" Visibility="Hidden" />

    <TextBox Name="ItemRespSearch"  Visibility="Hidden">
       <TextBox.Text>
          <MultiBinding StringFormat="{}{0}{1}{2}">
             <Binding ElementName="RespDummy1" Path="Text" />
             <Binding ElementName="RespText" Path="Text" />
             <Binding ElementName="RespDummy2" Path="Text" />
          </MultiBinding>
       </TextBox.Text>
    </TextBox>

2. The other way is using the run command to concatenate.
This was unknown for me until a week ago, but Heiko was nice and shared it .

In the end, both will give you the same output.

</pre>
<TextBox Name="ItemTypeText" Text=""  />

<TextBlock Name="ItemTypeSearch" Visibility="Hidden">
       <TextBlock.Inlines>
         <Run Text="related:[ITEM_ITTY(&quot;" />
         <Run Text="{Binding ElementName=ItemTypeText,Path=Text}" />
         <Run Text="&quot;)]" />
       </TextBlock.Inlines>
     </TextBlock>

You have to add the string query to the TargetKey itself. If you put it as the value you might get some bad output.
You can set the TargetKey to “Query” and the string as value, but that will kill all your other inputs.

<Button Content="Search" Margin="0,0,0,0" Style="{DynamicResource styleButtonPrimaryMashup}">
             <Button.CommandParameter>
                <mashup:Events>
                   <mashup:Event SourceEventName="Click" TargetName="MMS200" TargetEventName="Search">
                      <mashup:Parameter TargetKey="FUDS" Value="{Binding Path=Text, ElementName=NameText}" />
                       <mashup:Parameter TargetKey="{Binding Path=Text, ElementName=ItemRespSearch}" Value="{Binding Path=Text, ElementName=ItemRespCheck}" />
                       <mashup:Parameter TargetKey="{Binding Path=Text, ElementName=ItemTypeSearch}" Value="{Binding Path=Text, ElementName=ItemTypeCheck}" />
                 </mashup:Event>

As you can see I am binding some values.
If the Value is blank the search will not be performed, so I’m just using this to check for any input.

If there is any input to the “RespText” the value will be set to ‘;’ .
You can use standard mashup conditions instead of the MultiDataTrigger as shown below.

<TextBox Name="ItemRespCheck" Visibility="Hidden">
       <TextBox.Style>
       <Style x:Key="ItemRespCheck" TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
          <Setter Property="Text" Value=";" />
          <Style.Triggers>
             <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                   <Condition Binding="{Binding ElementName=RespText, Path=Text}" Value="" />
                </MultiDataTrigger.Conditions>
                <Setter Property="Text" Value="" />
             </MultiDataTrigger>
          </Style.Triggers>
       </Style>
    </TextBox.Style>
    </TextBox>

And the final string query will be like this if you provide input to all 3.

FUDS:(A*) related:[ITEM_RESP(“141254”)]:(;) related:[ITEM_ITTY(“031”)]:(;)
If you are trying and failing with this, I strongly recommand using Fiddler or similar to see what output the mashup sends.

Attached is a full sample containing both the related search and changing view/sorting orders option.
You probably have to change some of the static values I’ve added to make it work.

<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>
    </Grid.Resources>

    <Grid.ColumnDefinitions>
       <ColumnDefinition Width="*" />

    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
       <RowDefinition Height="30" />
       <RowDefinition Height="*" />
    </Grid.RowDefinitions>

    <StackPanel Grid.Row="0" Grid.Column="0" Orientation="Horizontal">
          <TextBlock Text="Name:" />
          <TextBox Name="NameText" MaxWidth="80" MinWidth="80" />
          <TextBlock Text="Item responsible:" />
          <TextBox Name="RespText" Text="" MaxWidth="80" MinWidth="80" />
          <TextBlock Text="Item Type:" />
          <TextBox Name="ItemTypeText" Text="" MaxWidth="80" MinWidth="80" />

          <Button Content="Search" Margin="0,0,0,0" Style="{DynamicResource styleButtonPrimaryMashup}">
             <Button.CommandParameter>
                <mashup:Events>
                   <mashup:Event SourceEventName="Click" TargetName="MMS200" TargetEventName="Search">
                      <mashup:Parameter TargetKey="FUDS" Value="{Binding Path=Text, ElementName=NameText}" />
                         <mashup:Parameter TargetKey="{Binding Path=Text, ElementName=ItemRespSearch}" Value="{Binding Path=Text, ElementName=ItemRespCheck}" />
                          <mashup:Parameter TargetKey="{Binding Path=Text, ElementName=ItemTypeSearch}" Value="{Binding Path=Text, ElementName=ItemTypeCheck}" />
                   </mashup:Event>

                      <mashup:Event TargetName="MMS200" SourceEventName="Click" TargetEventName="Apply">
                      <mashup:Event.Conditions>
                         <mashup:Conditions>
                            <mashup:Condition SourceValue="{Binding Path=Text, ElementName=RespText}" TargetValue="" Operator="Equal" />
                         </mashup:Conditions>
                      </mashup:Event.Conditions>
                      <mashup:Parameter TargetKey="WWQTTP" Value="7" />
                   </mashup:Event>

                      <mashup:Event TargetName="MMS200" SourceEventName="Click" TargetEventName="Apply">
                      <mashup:Event.Conditions>
                         <mashup:Conditions>
                            <mashup:Condition SourceValue="{Binding Path=Text, ElementName=RespText}" TargetValue="" Operator="NotEqual" />
                         </mashup:Conditions>
                      </mashup:Event.Conditions>
                      <mashup:Parameter TargetKey="WWQTTP" Value="5" />

                   </mashup:Event>

                </mashup:Events>
             </Button.CommandParameter>
          </Button>

          <TextBlock Text="View" HorizontalAlignment="Right" />

          <ComboBox Name="ItemMasterChangeView" MinWidth="85" MinHeight="20" MaxWidth="85" MaxHeight="70" Margin="5">
             <mashup:Event.SelectionChanged>
                <mashup:Events>
                   <mashup:Event SourceEventName="SelectionChanged" TargetName="MMS200" TargetEventName="Apply">
                      <mashup:Event.Conditions>
                         <mashup:Conditions>
                            <mashup:Condition TargetKey="Value" SourceValue="{Binding ElementName=ItemMasterChangeView, Path=SelectedIndex}" TargetValue="1" Operator="Equal" />
                         </mashup:Conditions>
                      </mashup:Event.Conditions>
                      <mashup:Parameter TargetKey="WWFACI" Value="100" />
                      <mashup:Parameter TargetKey="WWWHLO" Value="100" />
                      <mashup:Parameter TargetKey="WOPAVR" Value="{Binding ElementName=ONHAND, Path=Content}" />
                   </mashup:Event>

                   <mashup:Event SourceEventName="SelectionChanged" TargetName="MMS200" TargetEventName="Apply">
                      <mashup:Event.Conditions>
                         <mashup:Conditions>
                            <mashup:Condition TargetKey="Value" SourceValue="{Binding ElementName=ItemMasterChangeView, Path=SelectedIndex}" TargetValue="2" Operator="Equal" />
                         </mashup:Conditions>
                      </mashup:Event.Conditions>
                      <mashup:Parameter TargetKey="WWFACI" Value="100" />
                      <mashup:Parameter TargetKey="WWWHLO" Value="100" />
                      <mashup:Parameter TargetKey="WOPAVR" Value="{Binding ElementName=WHS, Path=Content}" />
                   </mashup:Event>
                </mashup:Events>
             </mashup:Event.SelectionChanged>
             <ComboBoxItem Name="BLANK" Content="" />
             <ComboBoxItem Name="ONHAND" Content="ONHAND" />
             <ComboBoxItem Name="WHS" Content="WHS" />

          </ComboBox>

    </StackPanel>

    <TextBox Name="RespDummy1" Text="related:[ITEM_RESP(&quot;" Grid.Row="0" Visibility="Hidden" />
    <TextBox Name="RespDummy2" Text="&quot;)]" Visibility="Hidden" />

    <TextBox Name="ItemRespSearch" Grid.Row="0" Grid.Column="3" Visibility="Hidden">
       <TextBox.Text>
          <MultiBinding StringFormat="{}{0}{1}{2}">
             <Binding ElementName="RespDummy1" Path="Text" />
             <Binding ElementName="RespText" Path="Text" />
             <Binding ElementName="RespDummy2" Path="Text" />
          </MultiBinding>
       </TextBox.Text>
    </TextBox>

    <TextBlock Name="ItemTypeSearch" Visibility="Hidden">
       <TextBlock.Inlines>
         <Run Text="related:[ITEM_ITTY(&quot;" />
         <Run Text="{Binding ElementName=ItemTypeText,Path=Text}" />
         <Run Text="&quot;)]" />
       </TextBlock.Inlines>
     </TextBlock>

       <TextBox Name="ItemRespCheck" Visibility="Hidden">
       <TextBox.Style>
       <Style x:Key="ItemRespCheck" TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
          <Setter Property="Text" Value=";" />
          <Style.Triggers>
             <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                   <Condition Binding="{Binding ElementName=RespText, Path=Text}" Value="" />
                </MultiDataTrigger.Conditions>
                <Setter Property="Text" Value="" />
             </MultiDataTrigger>
          </Style.Triggers>
       </Style>
    </TextBox.Style>
    </TextBox>

       <TextBox Name="ItemTypeCheck" Visibility="Hidden">
       <TextBox.Style>
       <Style x:Key="ItemTypeCheck" TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
          <Setter Property="Text" Value=";" />
          <Style.Triggers>
             <MultiDataTrigger>
                <MultiDataTrigger.Conditions>
                   <Condition Binding="{Binding ElementName=ItemTypeText, Path=Text}" Value="" />
                </MultiDataTrigger.Conditions>
                <Setter Property="Text" Value="" />
             </MultiDataTrigger>
          </Style.Triggers>
       </Style>
    </TextBox.Style>
    </TextBox>

    <m3:ListPanel Name="MMS200" Grid.Row="1" IsListHeaderVisible="True" IsListHeaderExpanded="True">
       <m3:ListPanel.Events>
          <mashup:Events>
             <mashup:Event SourceEventName="Startup">
                <mashup:Parameter TargetKey="MBCONO" />
                <mashup:Parameter TargetKey="MBWHLO" />
                <mashup:Parameter TargetKey="MBITNO" />
                <mashup:Parameter TargetKey="WWFACI" Value="100" />
                <mashup:Parameter TargetKey="WWWHLO" Value="100" />
                <mashup:Parameter TargetKey="WWQTTP" Value="5" />
             </mashup:Event>
          </mashup:Events>
       </m3:ListPanel.Events>
       <m3:ListPanel.Bookmark>
          <m3:Bookmark Program="MMS200" Table="MITBAL" KeyNames="MBCONO,MBWHLO,MBITNO" FieldNames="WWFACI,WWHLO,WOPAVR,WWQTTP" />
       </m3:ListPanel.Bookmark>
    </m3:ListPanel>

 </Grid>

Regards
Ken Eric

Mashup – Adding a ContextMenu to the ListView

This week I will show you how you can add a ContextMenu to your ListView.
This is one of these small things that sometimes takes quite some time to figure out.
My major problem with getting the ContextMenu to work in the ListView was to get the actually ‘Click’ working.

Today I will provide you with a working .xaml sample containing some of the basic options from MMS001 using bookmark URI’s.
Related Options , Change, Copy, Delete, Display and Links.
You probably have to set your own values to ITGR and CONO to get it to run.
I also added a little bit of styling, in case this is unknown to some of you.

Here is a snapshot of the result:

ContextMenu

And the code:

<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>
    </Grid.Resources>

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



 <m3:MIListPanel Name="MMS200MIList">
       <m3:MIListPanel.Events>
          <mashup:Events>
             <mashup:Event SourceEventName="Startup">
                <mashup:Parameter TargetKey="ITGR" Value="03.01" />
             </mashup:Event>
          </mashup:Events>
       </m3:MIListPanel.Events>
       <m3:MIListPanel.DataSource>
          <m3:MIDataSource Program="MMS200MI" Transaction="LstItmByItmGr" Type="List" InputFields="ITGR" OutputFields="ITNO,ITTY,INDI" MaxReturnedRecords="20" />
       </m3:MIListPanel.DataSource>

       <ListView Name="MMS200MIListView" ItemsSource="{Binding Items}" Style="{DynamicResource styleListView}" ItemContainerStyle="{DynamicResource styleListViewItem}">

          <ListView.ContextMenu>
             <ContextMenu>

                <MenuItem Header="Related options">
                   <MenuItem.Style>
                      <Style x:Key="Triggers" TargetType="{x:Type MenuItem}">
                         <Style.Triggers>
                            <Trigger Property="MenuItem.IsMouseOver" Value="true">
                               <Setter Property="Foreground" Value="Red" />
                            </Trigger>
                         </Style.Triggers>
                      </Style>
                   </MenuItem.Style>

                   <MenuItem Header="Material plan" Command="mashup:MashupInstance.MashupCommand">
                      <MenuItem.CommandParameter>
                         <mashup:Events>
                            <mashup:Event SourceEventName="Click" LinkUri="mforms://bookmark?program=MMS001&amp;tablename=MITMAS&amp;keys=MMCONO%2c{CONO}%2cMMITNO%2c{ITNO}%2b%2b%2b%2b%2b%2b%2b%2b%2b&amp;option=34&amp;panel=E&amp;name=MMS001%2fE+Bookmark&amp;source=MForms">
                               <mashup:Parameter TargetKey="ITNO" Value="{Binding [ITNO]}" />
                               <mashup:Parameter TargetKey="CONO" Value="001" />
                            </mashup:Event>
                         </mashup:Events>
                      </MenuItem.CommandParameter>
                   </MenuItem>

                </MenuItem>

                <MenuItem Header="Change" Command="mashup:MashupInstance.MashupCommand">
                   <MenuItem.Style>
                      <Style x:Key="Triggers" TargetType="{x:Type MenuItem}">
                         <Setter Property="FontWeight" Value="Bold" />
                      </Style>
                   </MenuItem.Style>
                   <MenuItem.CommandParameter>
                      <mashup:Events>
                         <mashup:Event SourceEventName="Click" LinkUri="mforms://bookmark?program=MMS001&amp;tablename=MITMAS&amp;keys=MMCONO%2c{CONO}%2cMMITNO%2c{ITNO}%2b%2b%2b%2b%2b%2b%2b%2b%2b&amp;option=2&amp;panel=E&amp;name=MMS001%2fE+Bookmark&amp;source=MForms">
                            <mashup:Parameter TargetKey="ITNO" Value="{Binding [ITNO]}" />
                            <mashup:Parameter TargetKey="CONO" Value="001" />
                         </mashup:Event>
                      </mashup:Events>
                   </MenuItem.CommandParameter>
                </MenuItem>

                <MenuItem Header="Copy" Command="mashup:MashupInstance.MashupCommand">
                   <MenuItem.CommandParameter>
                      <mashup:Events>
                         <mashup:Event SourceEventName="Click" LinkUri="mforms://bookmark?program=MMS001&amp;tablename=MITMAS&amp;keys=MMCONO%2c{CONO}%2cMMITNO%2c{ITNO}%2b%2b%2b%2b%2b%2b%2b%2b%2b&amp;option=3&amp;panel=E&amp;name=MMS001%2fE+Bookmark&amp;source=MForms">
                            <mashup:Parameter TargetKey="ITNO" Value="{Binding [ITNO]}" />
                            <mashup:Parameter TargetKey="CONO" Value="001" />
                         </mashup:Event>
                      </mashup:Events>
                   </MenuItem.CommandParameter>
                </MenuItem>

                <MenuItem Header="Delete" Command="mashup:MashupInstance.MashupCommand">
                   <MenuItem.CommandParameter>
                      <mashup:Events>
                         <mashup:Event SourceEventName="Click" LinkUri="mforms://bookmark?program=MMS001&amp;tablename=MITMAS&amp;keys=MMCONO%2c{CONO}%2cMMITNO%2c{ITNO}%2b%2b%2b%2b%2b%2b%2b%2b%2b&amp;option=4&amp;panel=E&amp;name=MMS001%2fE+Bookmark&amp;source=MForms">
                            <mashup:Parameter TargetKey="ITNO" Value="{Binding [ITNO]}" />
                            <mashup:Parameter TargetKey="CONO" Value="001" />
                         </mashup:Event>
                      </mashup:Events>
                   </MenuItem.CommandParameter>
                </MenuItem>

                <MenuItem Header="Display" Command="mashup:MashupInstance.MashupCommand">
                   <MenuItem.CommandParameter>
                      <mashup:Events>
                         <mashup:Event SourceEventName="Click" LinkUri="mforms://bookmark?program=MMS001&amp;tablename=MITMAS&amp;keys=MMCONO%2c{CONO}%2cMMITNO%2c{ITNO}%2b%2b%2b%2b%2b%2b%2b%2b%2b&amp;option=5&amp;panel=E&amp;name=MMS001%2fE+Bookmark&amp;source=MForms">
                            <mashup:Parameter TargetKey="ITNO" Value="{Binding [ITNO]}" />
                            <mashup:Parameter TargetKey="CONO" Value="001" />
                         </mashup:Event>
                      </mashup:Events>
                   </MenuItem.CommandParameter>
                </MenuItem>

                <MenuItem Header="Links">
                   <MenuItem Header="https://thibaudatwork.wordpress.com" Command="mashup:MashupInstance.MashupCommand">
                      <MenuItem.CommandParameter>
                         <mashup:Events>
                            <mashup:Event SourceEventName="Click" LinkUri="https://thibaudatwork.wordpress.com" LinkIsExternal="True">
                                     </mashup:Event>
                         </mashup:Events>
                      </MenuItem.CommandParameter>
                   </MenuItem>

                </MenuItem>
             </ContextMenu>
          </ListView.ContextMenu>

          <ListView.View>
             <GridView ColumnHeaderContainerStyle="{DynamicResource styleGridViewColumnHeader}">
                <GridView.Columns>
                   <GridViewColumn Header="Item:" DisplayMemberBinding="{Binding [ITNO]}" />
                   <GridViewColumn Header="Item type:" DisplayMemberBinding="{Binding [ITTY]}" />
                   <GridViewColumn Header="Lot ctrl:" DisplayMemberBinding="{Binding [INDI]}" />
                </GridView.Columns>
             </GridView>
          </ListView.View>
       </ListView>
    </m3:MIListPanel>

    <ui:StatusBar Name="StatusBar" Grid.Row="1" Grid.Column="0" />
 </Grid>

Regards
Ken Eric

Mashup – GridView and CellTemplate

Today I will share some of my experience with the GridView in combination with MIListPanel and MIPanel. It’s a pretty simple solution, but I spent quite some time myself getting it to work the first time, so I hope it’s worth sharing.

My case scenario was to work with multiple lines. I wanted to be able to edit and update in a more “practical” way than having to select a line and then edit from a different panel followed by clicking a button. Sometimes it can be feel to “slow”, and sometimes it just takes too much space.

What I tried to do, was to create an all-in-one solution, by using the GridViewColumn.CellTemplate and actually open the cell in the GridView for editing and adding a button for update. It takes less space, and when processing multiple lines, it sure does feel a lot more user friendly than some of my previous solutions when I first started working with mashup.

The .xaml sample will look something like this:
GridView-Example1

The list is based on CRS620MI, LstSuppliers. The button is connected to the CRS620MI, UpdSupplier. Using the GridViewColumn.CellTemplate will allow you to create a DataTemplate inside the cell, and I think you can do pretty much anything you want when working with DataTemplate.

Here is also a few different scenarios as well using the same method.

Example one is built for speed, when you need to repeat the same task multiple times based on a list.

GridView-Example2

Example two allows you to provide more input. In this case I built a popup inside the CellTemplate. To learn how to create the popup see my previous post .


<TabItem Header="Attached items">
 <StackPanel>

    <m3:MIListPanel Name="MOS256List">
                <m3:MIListPanel.Events>
                   <mashup:Events>
                      <mashup:Event SourceEventName="CurrentItemChanged" SourceName="MMS240List2">
                         <mashup:Parameter TargetKey="MTRL" SourceKey="ITNO" />
                         <mashup:Parameter TargetKey="SERN" SourceKey="SERN" />
                         <mashup:Parameter TargetKey="EXPA" Value="Y" />
                      </mashup:Event>
                   </mashup:Events>
                </m3:MIListPanel.Events>
                <m3:MIListPanel.DataSource>
                   <m3:MIDataSource Program="MOS256MI" Transaction="LstAsBuildLevel" Type="List" InputFields="MTRL,SERN" OutputFields="MTRL,SERN,CFGL,ITNO,SER2,ITDS,LVLS,TX40,MES1,MES2,MES3,MES4,MVA1,MVA2,MVA3,MVA4,STAT" MaxReturnedRecords="50" />
                </m3:MIListPanel.DataSource>

                <ListView ItemsSource="{Binding Items}" Style="{DynamicResource styleListView}" ItemContainerStyle="{DynamicResource styleListViewItem}">
                   <ListView.View>
                      <GridView ColumnHeaderContainerStyle="{DynamicResource styleGridViewColumnHeader}">
                         <GridView.Columns>
                            <GridViewColumn Header="Lvl:" DisplayMemberBinding="{Binding [LVLS]}" />
                            <GridViewColumn Header="Configuration:" DisplayMemberBinding="{Binding [CFGL]}" />
                            <GridViewColumn Header="Position:" DisplayMemberBinding="{Binding [TX40]}" />
                            <GridViewColumn Header="S/N" DisplayMemberBinding="{Binding [SER2]}" />
                            <GridViewColumn Header="Item" DisplayMemberBinding="{Binding [ITNO]}" />
                            <GridViewColumn Header="Descripton:" DisplayMemberBinding="{Binding [ITDS]}" />
                            <GridViewColumn Header="Days:" DisplayMemberBinding="{Binding [MVA1]}" />
                            <GridViewColumn Header="Runs:" DisplayMemberBinding="{Binding [MVA2]}" />
                            <GridViewColumn Header="Hours:" DisplayMemberBinding="{Binding [MVA3]}" />
                            <GridViewColumn Header="Remove">
                               <GridViewColumn.CellTemplate>
                                  <DataTemplate>
                                     <StackPanel>
                                        <ToggleButton Name="button">
                                           <ToggleButton.Template>
                                              <ControlTemplate TargetType="ToggleButton">
                                                 <TextBlock Text="Remove" Foreground="#FFE10101" TextDecorations="Underline" />
                                              </ControlTemplate>
                                           </ToggleButton.Template>
                                        </ToggleButton>

                                        <Popup IsOpen="{Binding IsChecked, ElementName=button, Mode=OneWay}" Width="300" Height="200" Popup.StaysOpen="False">
                                           <Border Background="White" BorderBrush="Black" BorderThickness="2">
                                              <Grid>
                                                 <Grid.RowDefinitions>
                                                    <RowDefinition Height="200" />
                                                 </Grid.RowDefinitions>
                                                 <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="300" />
                                                 </Grid.ColumnDefinitions>
                                                 <StackPanel>
                                                    <GroupBox Header="Remove unit" Style="{DynamicResource styleGroupLineMashup}">
                                                       <Grid Margin="0,0,0,8">
                                                          <Grid.ColumnDefinitions>
                                                             <ColumnDefinition Width="100" />
                                                             <ColumnDefinition Width="200" />
                                                          </Grid.ColumnDefinitions>
                                                          <Grid.RowDefinitions>
                                                             <RowDefinition Height="32" />
                                                             <RowDefinition Height="32" />
                                                             <RowDefinition Height="32" />
                                                             <RowDefinition Height="32" />
                                                             <RowDefinition Height="32" />
                                                          </Grid.RowDefinitions>

                                                          <TextBlock Text="Serial number:" Grid.Row="0" Grid.Column="0" Margin="8,8,0,0" />
                                                          <TextBox Text="{Binding [SER2]}" Grid.Row="0" Grid.Column="1" MinWidth="115" MaxWidth="115" HorizontalAlignment="Left" IsEnabled="False" />
                                                          <TextBlock Text="Item number:" Grid.Row="1" Grid.Column="0" Margin="8,8,0,0" />
                                                          <TextBox Text="{Binding [ITNO]}" Grid.Row="1" Grid.Column="1" MinWidth="80" MaxWidth="80" HorizontalAlignment="Left" IsEnabled="False" />
                                                          <TextBlock Text="To location:" Grid.Row="2" Grid.Column="0" Margin="8,8,0,0" />
                                                          <TextBox Name="RemoveLocation" Text="" Grid.Row="2" Grid.Column="1" MinWidth="115" MaxWidth="80" HorizontalAlignment="Left" />
                                                          <TextBlock Text="Warehouse:" Grid.Row="3" Grid.Column="0" Margin="8,8,0,0" />
                                                          <TextBox Name="RemoveWhs" Text="100" Grid.Row="3" Grid.Column="1" MinWidth="40" MaxWidth="40" HorizontalAlignment="Left" />

                                                          <Button Name="Install" Content="Remove" Grid.Row="4" Grid.Column="1" HorizontalAlignment="Left" Margin="0,0,50,0">
                                                             <Button.CommandParameter>
                                                                <mashup:Events>
                                                                   <mashup:Event SourceEventName="Click" TargetName="RemoveInstall" TargetEventName="Update" Debug="True">
                                                                      <mashup:Parameter TargetKey="RITP" Value="R" />
                                                                      <mashup:Parameter TargetKey="RESP" Value="202231" />
                                                                      <mashup:Parameter TargetKey="TRDT" Value="20130927" />
                                                                      <mashup:Parameter TargetKey="TRTM" Value="090909" />
                                                                      <mashup:Parameter TargetKey="WHLO" Value="{Binding Path=Text, ElementName=RemoveWhs}" />
                                                                      <mashup:Parameter TargetKey="RSC4" Value="CHG" />
                                                                      <mashup:Parameter TargetKey="ITNR" Value="{Binding [ITNO]}" />
                                                                      <mashup:Parameter TargetKey="BANR" Value="{Binding [SER2]}" />
                                                                      <mashup:Parameter TargetKey="TWSL" Value="{Binding Path=Text, ElementName=RemoveLocation}" />
                                                                      <mashup:Parameter TargetKey="NHAR" Value="{Binding [MTRL]}" />
                                                                      <mashup:Parameter TargetKey="NHSR" Value="{Binding [SERN]}" />
                                                                      <mashup:Parameter TargetKey="CFGR" Value="{Binding [CFGL]}" />
                                                                   </mashup:Event>
                                                                </mashup:Events>
                                                             </Button.CommandParameter>
                                                          </Button>
                                                       </Grid>
                                                    </GroupBox>
                                                 </StackPanel>
                                              </Grid>
                                           </Border>
                                        </Popup>
                                     </StackPanel>
                                  </DataTemplate>
                               </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                         </GridView.Columns>
                      </GridView>
                   </ListView.View>
                </ListView>
             </m3:MIListPanel>

             <m3:MIPanel Name="RemoveInstall">
                <m3:MIPanel.Events>
                   <mashup:Events>
                      <mashup:Event SourceName="RemoveInstall" TargetName="MOS256List" SourceEventName="UpdateComplete" TargetEventName="Refresh" />
                   </mashup:Events>
                </m3:MIPanel.Events>

                <m3:MIPanel.DataSource>
                   <m3:MIDataSource Program="MOS125MI" Transaction="RemoveInstall" InputFields="RITP,RESP,TRDT,TRTM,WHLO,RSC4,ITNR,BANR,TWSL,NHAR,NHSR,CFGR" />
                </m3:MIPanel.DataSource>
             </m3:MIPanel>

    </StackPanel>
    </TabItem>

 

GridView-Example4

The source code of the sample:

<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>
    </Grid.Resources>

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

       <m3:MIListPanel Name="CRS620MIList">
       <m3:MIListPanel.Events>
          <mashup:Events>
             <mashup:Event SourceEventName="Startup" />
          </mashup:Events>
       </m3:MIListPanel.Events>

       <m3:MIListPanel.DataSource>
          <m3:MIDataSource Program="CRS620MI" Transaction="LstSuppliers" Type="List" OutputFields="SUNO,SUNM,PHNO,CUCD,BUYE" MaxReturnedRecords="4" />
       </m3:MIListPanel.DataSource>

       <ListView ItemsSource="{Binding Items}" Style="{DynamicResource styleListView}" ItemContainerStyle="{DynamicResource styleListViewItem}">
          <ListView.View>
             <GridView ColumnHeaderContainerStyle="{DynamicResource styleGridViewColumnHeader}">
                <GridView.Columns>
                   <GridViewColumn Header="Supplier:" DisplayMemberBinding="{Binding [SUNO]}" />

                   <GridViewColumn Header="Supplier Name:">
                      <GridViewColumn.CellTemplate>
                         <DataTemplate>
                            <TextBox Name="Name" Text="{Binding [SUNM]}" />
                         </DataTemplate>
                      </GridViewColumn.CellTemplate>
                   </GridViewColumn>

                   <GridViewColumn Header="Phone:">
                      <GridViewColumn.CellTemplate>
                         <DataTemplate>
                            <TextBox Name="Phone" Text="{Binding [PHNO]}" />
                         </DataTemplate>
                      </GridViewColumn.CellTemplate>
                   </GridViewColumn>

                   <GridViewColumn Header="Currency:">
                      <GridViewColumn.CellTemplate>
                         <DataTemplate>
                            <TextBox Name="Currency" Text="{Binding [CUCD]}" />
                         </DataTemplate>
                      </GridViewColumn.CellTemplate>
                   </GridViewColumn>

                      <GridViewColumn Header="Buyer:">
                      <GridViewColumn.CellTemplate>
                         <DataTemplate>
                            <TextBox Name="Buyer" Text="{Binding [BUYE]}" />
                         </DataTemplate>
                      </GridViewColumn.CellTemplate>
                   </GridViewColumn>

                   <GridViewColumn>
                      <GridViewColumn.CellTemplate>
                         <DataTemplate>
                            <Button Content="Update">
                               <Button.CommandParameter>
                                  <mashup:Events>
                                     <mashup:Event SourceEventName="Click" TargetName="CRS620Update" TargetEventName="Update">
                                        <mashup:Parameter TargetKey="SUNO" Value="{Binding [SUNO]}" />
                                        <mashup:Parameter TargetKey="SUNM" Value="{Binding [SUNM]}" />
                                        <mashup:Parameter TargetKey="PHNO" Value="{Binding [PHNO]}" />
                                        <mashup:Parameter TargetKey="CUCD" Value="{Binding [CUCD]}" />
                                        <mashup:Parameter TargetKey="BUYE" Value="{Binding [BUYE]}" />
                                     </mashup:Event>
                                  </mashup:Events>
                               </Button.CommandParameter>
                            </Button>
                         </DataTemplate>
                      </GridViewColumn.CellTemplate>
                   </GridViewColumn>
                </GridView.Columns>
             </GridView>
          </ListView.View>
       </ListView>

    </m3:MIListPanel>
    <m3:MIPanel Name="CRS620Update">
       <m3:MIPanel.DataSource>
          <m3:MIDataSource Program="CRS620MI" Transaction="UpdSupplier" Type="Update" InputFields="SUNO,SUNM,PHNO,CUCD,BUYE" MandatoryInputFields="SUNO" />
       </m3:MIPanel.DataSource>
    </m3:MIPanel>

    <ui:StatusBar Name="StatusBar" Grid.Row="1" Grid.Column="0" />
 </Grid>

Regards
Ken Eric