| ||
English | Slovak |
Menu: | |||||||||
|
Components of Px Framework: PxGreatRepeater - component for entering data with repeating structure, maximum number of values is limitedThe PxGreatRepeater component is used to input data with cyclically repeating structure. Simple example of repeating data is a person who has got a telephone number or several phone numbers. The picture below shows the PxGreatRepeater control element for entering the phone number: Of course it is possible to enter more phone numbers using the PxGreatRepeater control element, see the picture below: Press the "+" button to add new boxes for entering the phone number, press the "-" button to delete the existing numbers. The example below shows how it works in practice. Add the following columns to the directory table:
Tel1 VARCHAR2(50),
As you can see we have entered the phone entry (tel1, tel2, tel3) three times to the Adresar table. Thus, during entering the phone number, and its note we will be limited, we will be able to enter only three phone numbers with a note. Entering and deleting, can be carried out by means of the "+" and "-" buttons.. To link the PxGreatRepeater component to the PxWebQuery component, apply the AddParamGreatWebQuery parameter to the PxWebQuery component. For the correct functioning of the PxGreatRepeater component apply the AddParamGreatWebQuery parameter to the PxWebQuery component, which shall display or operate with such structured data. The AddParamGreatWebQuery parameter definition is as follows:
wquAdresar.AddParamGreatWebQuery("Telefon", "Tel1;Tel_Pozn1", "Tel1 - Tel_Pozn1", 3, "mvNormal");
Description of the parameters of the AddParamGreatWebQuery method: C# syntax: public void AddParamGreatWebQuery(string aFieldName, string aEditAllFieldNames, string aExpresionToView, Int16 aMaxRepeatCount, string aModeToView) Description of the parameters: aFieldName - Name of the column that is created as a new column in the table, to which the AddParamGreatWebQuery method is applied, and to which the PxGreatRepeater component is linked (this column name must be unique, no other table column with such name shall exist). aEditAllFieldNames - Lists all names of the columns to be edited in the PxGreatRepeater component in exactly the same order they shall be listed in the PxGreatRepeater component. The individual columns are separated by a semicolon. The names of the columns shall be composed of columns which are cyclically repeated, i.e. Tel1 .. to .. Tel3. The name of the column that starts with the number 1 shall always be entered. aExpresionToView - Lists all names of the columns to be displayed in the Grid. These names may be separated by a comma or a hyphen, which shall appear during the display in the Grid (PxSuperGrid). aMaxRepeatCount - This value defines the maximum number of phone numbers which can be entered via the PxGreatRepeater component. If the contains tel1, tel2, tel3 columns then this variable shall equate to 3. aModeToView - This string defines data display in the PxSuperGrid component, in our case of the column defined in the aFieldName entry. The existing display modes are as follows: mvBreakHR, mvLineNumber a mvNormal. If the "Tel1 - Tel_Pozn1" string is entered to the ExpresionToView entry and the display mode is selected mvNormal , the display in the PxSuperGrid component shall look like this: If the "Tel1 - Tel_Pozn1" string is entered to the ExpresionToView entry and the display mode is selected mvBreakHR, the display in the PxSuperGrid component shall look like this: If the "Tel1 - Tel_Pozn1" string is entered to the ExpresionToView entry and the display mode is selected mvLineNumber, the display in the PxSuperGrid component shall look like this: To reduce the number of columns displayed in the grid use the VisibleFields property of the PxSuperGrid component. See the picture below:
grdAdresar.VisibleFields = "name;idpravnaforma;address;miesto;telefon";
Assign to the VisibleFields property the names of the columns separated by a semicolon which are to be displayed in the PxSuperGrid component. If no value is assigned in the VisibleFields property all columns (fields) shall be displayed in the PxSuperGrid component. Of course all columns in the PxSuperGrid component shall be displayed in exactly the same order they have been entered to the VisibleFields property. For the proper functioning of the VisibleFields property it shall be defined before linking and binding to the PxWebQuery component. The VisibleFields property can also be used to define the length of the column (by typing a colon after each column and the number of pixels that shall define the length of the column). See the example below:
grdAdresar.VisibleFields = "name:150;idpravnaforma;address:180;miesto:150;telefon";
The resulting PxSuperGrid shall be as follows: The next image contains listing of the Adresar.aspx.cs, file source code for application of the AddParamGreatWebQuery parameter to the wquAdresar component. The example shows entering of two parameters, i.e. telephone and fax numbers:
protected void Page_Load(object sender, EventArgs e)
If you want to use the PxGreatRepeater component for editing in the AddAdresar.aspx form, it shall be defined in this file as follows:
<Prx:PxWebQuery ID="wquAdresar" runat="server" Value="wquAdresar"/>
Link the PxGreatRepeater component to the wquAdresar component in the AddAdresar.aspx.cs file, this linking shall as follows:
gtrTelefon.PxDataSource = wquAdresar;
The PxFlyComboBox component does not support alignments and AddTableRow, TableBegin TableEnd properties, which are supported by other components like PxEdit, etc., that is why it is necessary to use the <BR /> tag. Titles in the Grid (Title) and captions in the PxGreatRepeater component can be defined centrally, during the definition of the wquAdresar component:
wquAdresar.Columns["tel1"].Caption = "Telephone";
If everything is set up correctly, the resulting AddAdresar.aspx form shall look like this: The PxGreatRepeater component contains a function through which we can find the value set for each component that contains the PxGreatRepeater component. This method is called GetValue. Description of the parameters of the GetValue function: C# syntax:
public string GetValue(string aFieldName, Int32 aNumberRepeaterPanel);
Description of the parameters: aFieldName - name of the column which belongs to the given component that is contained in the PxGreatRepeater component. Usually these are the names of the columns that were specified in the AddParamGreatWebQuery parameters, namely those which have been entered into the expression aEditAllFieldNames. In the PxFlyComboBox component, located in PxGreatRepeater component, there is an overload of the aFieldName variable in a way that firstly the FieldName is entered, which defines the PxFlyComboBox component and then enter the name of the combobox field, separated by a semicolon. More examples: "Miesto1;IdOkres1" aNumberRepeaterPanel - number of panel from which a value should be loaded. Number of the first panel is 0. Maximum number of panels is limited by variable aMaxRepeatCount in AddParamGreatWebQuery parameter. Example of use of the GetValue method:
string sGetVal = gtrTelefon.GetValue("Tel1", 0);
In this example the GetValue function returns the value set in "Tel1" in the first panel. Example of use of the method and loading of a value from the PxFlyComboBox component, located in the PxGreatRepeater component:
string sGetVal = gtrMiesto.GetValue("Miesto1;IDOBEC1", 0);
In this example the GetValue function returns us the value of the district set in the PxFlyComboBox component, which is inserted in the PxGreatRepeater component. Here is a functional example of the PxGreatRepeater component, even with source code. This functional example on this site runs on MySQL 5.0 database.
Others articles of Px Framework:
It doesn't the intention of this part website, describe in detail the work with PxFramework components, a detailed description of the component available in manual, which can be downloaded here: Download manual of Px Framework |