Sk   En  

Components of Px Framework:

PxGreatRepeater - component for entering data with repeating structure, maximum number of values is limited

The 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:

Obrázok komponenty PxGreatRepeater

Of course it is possible to enter more phone numbers using the PxGreatRepeater control element, see the picture below:

Obrázok komponenty PxGreatRepeater - 3x

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),
Tel_Pozn1 VARCHAR2(50),
Tel2 VARCHAR2(50),
Tel_Pozn2 VARCHAR2(50),
Tel3 VARCHAR2(50),
Tel_Pozn3 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:

Komponenty PxGreatRepeater - mod mvNormal

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:

Komponenty PxGreatRepeater - mod mvBreakHR

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:

Komponenty PxGreatRepeater - mod mvLineNumber

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";
grdAdresar.PxDataSource = wquAdresar;

The resulting PxSuperGrid shall be as follows:

Komponenty PxGreatRepeater - zobrazenie v gride

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 ((!IsPostBack)&&(wquAdresar.Active==false))
    string sSQLText1 = "select IDPravForm as aKey, Name as aValue from PravForm Order By aValue";
    wquAdresar.ConnectString = "User Id=skodapeter;Password=aa;Data Source=xe;";

    wquAdresar.SQLSelect = @"select idadresar , name, address, idpravnaforma,
      create_date, invalid_adress, idkraj, idokres, idobec, tel1, tel_pozn1, tel2, tel_pozn2,
      tel3, tel_pozn3, fax1, fax_pozn1, fax2, fax_pozn2 from Adresar04";

    wquAdresar.AddParamKey("idpravnaforma", "aKey", "aValue", "aValue", "aKey", sSQLText1);
    wquAdresar.AddParamCheck("invalid_adress", "A", "N", false);
    wquAdresar.AddParamFlyComboBox("miesto", "idkraj;idokres;idobec", "idkraj;idokres;idobec",
      "kraj;okres;obec", "Obec;Okres;Kraj", "wquObec", "mvNameAndBR");

    wquAdresar.AddParamGreatWebQuery("Telefon", "Tel1;Tel_Pozn1", "Tel1 - Tel_Pozn1", 3,
    wquAdresar.AddParamGreatWebQuery("Fax", "Fax1;Fax_Pozn1", "Fax1 - Fax_Pozn1", 2, "");


    wquAdresar.Columns["idadresar"].Caption = "ID";
    wquAdresar.Columns["name"].Caption = "Persons Name";
    wquAdresar.Columns["idpravnaforma"].Caption = "Juridical Form";
    wquAdresar.Columns["address"].Caption = "Street";
    wquAdresar.Columns["create_date"].Caption = "Date of Establishment";
    wquAdresar.Columns["invalid_adress"].Caption = "Invalid address";
    wquAdresar.Columns["miesto"].Caption = "Municipality, District";
    wquAdresar.Columns["tel1"].Caption = "Telephone";
    wquAdresar.Columns["tel_pozn1"].Caption = "Notice";
    wquAdresar.Columns["tel2"].Caption = "Telephone";
    wquAdresar.Columns["tel_pozn2"].Caption = "Notice";
    wquAdresar.Columns["tel3"].Caption = "Telephone";
    wquAdresar.Columns["tel_pozn3"].Caption = "Notice";
    wquAdresar.Columns["fax1"].Caption = "Fax";
    wquAdresar.Columns["fax_pozn1"].Caption = "Notice";
    wquAdresar.Columns["fax2"].Caption = "Fax";
    wquAdresar.Columns["fax_pozn2"].Caption = "Notice";
    wquAdresar.Columns["telefon"].Caption = "Telephone";
  grdAdresar.VisibleFields = "name;idpravnaforma;address;miesto;telefon";
  grdAdresar.PxDataSource = wquAdresar;

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"/>

<Prx:PxEdit ID="edtIDADRESAR" runat="server" AddTableRow="True" TableBegin="True"></Prx:PxEdit>
<Prx:PxEdit ID="edtName" runat="server" AddTableRow="True" ></Prx:PxEdit>
<Prx:PxComboBox ID="cmbPravnaForma" runat="server" AddTableRow="True" ></Prx:PxComboBox>
<Prx:PxJSDatePicker ID="edtCREATE_DATE" runat="server" AddTableRow="True" ></Prx:PxJSDatePicker>
<Prx:PxCheckBox ID="chkInvalid_Adress" runat="server" AddTableRow="True" ></Prx:PxCheckBox>
<Prx:PxEdit ID="edtADDRESS" runat="server" AddTableRow="True" TableEnd="True"></Prx:PxEdit>
<Prx:PxFlyComboBox ID="fcmbMiesto" runat="server"></Prx:PxFlyComboBox>
<br />
<Prx:PxGreatRepeater ID="gtrTelefon" runat="server"></Prx:PxGreatRepeater>
<br />
<Prx:PxGreatRepeater ID="gtrFax" runat="server"></Prx:PxGreatRepeater>
<br />

Link the PxGreatRepeater component to the wquAdresar component in the AddAdresar.aspx.cs file, this linking shall as follows:

gtrTelefon.PxDataSource = wquAdresar;
gtrTelefon.FieldName = "telefon";

gtrFax.PxDataSource = wquAdresar;
gtrFax.FieldName = "fax";

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";
wquAdresar.Columns["tel_pozn1"].Caption = "Notice";
wquAdresar.Columns["tel2"].Caption = "Telephone";
wquAdresar.Columns["tel_pozn2"].Caption = "Notice";
wquAdresar.Columns["tel3"].Caption = "Telephone";
wquAdresar.Columns["tel_pozn3"].Caption = "Notice";
wquAdresar.Columns["fax1"].Caption = "Fax";
wquAdresar.Columns["fax_pozn1"].Caption = "Notice";
wquAdresar.Columns["fax2"].Caption = "Fax";
wquAdresar.Columns["fax_pozn2"].Caption = "Notice";
wquAdresar.Columns["telefon"].Caption = "Telephone";

If everything is set up correctly, the resulting AddAdresar.aspx form shall look like this:

Komponenta PxGreatRepeater - full zobrazenie

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.

No. Example Name Source Codes SQL Script
1.8. Adresar.aspx

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