Pass parameters to components

Top Previous Topic Next Topic  Print this topic

This section explains how to parse values for parameters defined in components. See the example below:

 

 

In this example we will use the repeating table showing below to create a component. We will define a parameter in the component for the Background attribute and then in the XFD document we will parse a value to this parameter to change the color.

 

parameters_components1

 

We assigned the cdcatalog.xml file as data source from the default instalation folder C:\Users\Public\Documents\Ecrion\XF Designer 2011\Samples\XML Samples\Template Samples.

To insert this repeating table, just drag the ns:cd node from the XML tree, drop it on the worksheet and select Repeating Table.

To give it a professional look, select the table, go to Design tab and select for example the third format. Also, you may add the option of alternating table row color. In order to do this, go to Formatting group under Home tab and click Conditional Formatting. From the drop-down list select the Alternate Table Row Color option.

 

After inserting the table, go to Navigation Bar, right click on the "table" object and select Make Component.

In the Make Component dialog enter the name and the path for the .xfc file and press OK.

 

parameters_components2

 

This action will open the .xfc file in a new XF Designer window were you will be able to define a parameter to your component.

 

parameters_components10

 

To add a new parameter, go to the Template group under the Home tab and select Edit Parameters.

 

parameters_components4

 

In the Parameters dialog click on the Add button and the Edit Parameter dialog will open.

 

parameters_components3

 

Enter "BackColor" in the Name field and a default value for the parameter you want to create, for example "red", and then click OK.

 

To validate the use of this parameter, in the Parameter dialog select the recent created parameter and click OK.

Right click on the "table" object in the Navigation Bar and select Properties.

Then go to Background section in the Properties pane and click on the arrow pointing in the right direction that is placed near the Color attribute.

 

parameters_components7

 

In the Property Value click on the arrow in the Dynamic Value from input XML field and this will open the Edit Expression dialog.

Go to Working Objects section and select Parameters. Select $BackColor from the Parameter Name like in the picture below and click OK.

 

parameters_components8

 

Save the .xfc file and then return to your XFD document to parse values to the parameter.

 

In this example we will change the background color of this component be parsing values to the BackColor parameter defined before in the component.

In order to do this, double click on the component and click the More button in the Property Value dialog.

 

parameters_components6

 

In the Parameters section click Add and the Edit Parameter dialog will open.

Here enter "Backcolor" in the Name field and "blue" in the Value field.

 

parameters_components5

 

Click OK and go to Print Layout to see the results.

 

parameters_components9