| ||
English | Slovak |
Menu: | |||||||||
|
Components of Px Framework: PxFlyComboBox - set of the consecutively linked comboboxes, suitable for the work with structured data (for example: selection of category and subcategory)The PxFlyComboBox component serves for value selection in case of structured lists, it is mostly used when an object is integrated into a category and subcategory. The PxFlyComboBox component may consist of several mutually related comboboxes (DropDownList components). There can be an optional number of such comboboxes - from 2 to n. See the picture below: The picture shows selection of the name of the municipality. Since there are nearly 3000 municipalities in Slovakia, it would have been difficult to choose from such list. The PxFlyComboBox component shall save the labour here. When the particular region is selected, only districts filtered for the given region shall be displayed in the combobox "district". When the certain district is chosen, only municipalities filtered for the given district shall be displayed in the combobox. However it is quite difficult to program such thin, but the PxFramework provides quick and cheap solution. For the correct functioning of the PxFlyComboBox component, it is necessary to apply the AddParamFlyComboBox parameter to the given PxWebQuery component, which shall display or work with such structured data. The definition of the AddParamFlyComboBox parameter is as follows:
wquAdresar.AddParamFlyComboBox("miesto", "idkraj;idokres;idobec",
Description of the parameters of the AddParamFlyComboBox method: C# syntax: public void AddParamFlyComboBox(string aFieldName, string aKeyFields, string aKeyDetailFields, string aValueFields, string aFieldToView, string aPxWebQueryName, string aModeToView) Description of the parameters: aFieldName - Name of the column, which is created as a new column in the table and to which the AddParamFlyComboBox method is applied and which is then liked to the PxFlyComboBox component (this column name must be unique, no other table column with such name shall exist). aKeyFields - String value to which keys of the main table columns are defined , to which during editing via the PxFlyComboBox the IDs are entered, in our case these are the IdKraj, IdOkres and IdObec. These columns are entered consequently in the way they are to be displayed in the PxFlyComboBox component. Individual columns are separated by a semicolon. aKeyDetailFields - String value to which keys of the classifier table columns are defined, from which during editing via the PxFlyComboBox component the IDs are loaded and entered to the main table. In our case these are the IdKraj,IdOkres and IdObec columns. These columns are entered consequently in the way they are to be displayed in the PxFlyComboBox component. Individual columns are separated by a semicolon. aValueFields - String value to which values of the classifier table columns are defined, which are displayed in the PxFlyComboBox component during editing via this component. In our case these are the IdKraj,IdOkres and IdObec columns. These columns are entered consequently in the way they are to be displayed in the PxFlyComboBox component. Individual columns are separated by a semicolon. aFieldToView - String value, which defines the names of the columns that are displayed in PxSuperGrid component, under the aFieldName column. Summary or listing of these columns may not be complete. These columns are entered consequently in the way they are to be displayed in the PxSuperGrid component. Individual columns are separated by a semicolon. aPxWebQueryName - Name of the PxWebQuery component, where the classifier of Region (Kraj), District(Okres) and Minicipality(Obec) is loaded. The classifier is formed by merging of three classifiers, in our case they are as follows: Ckraj, Cokres, CObec. 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: mvValueBR, mvNameAndBR a mvNormal. If the "Obec;Okres" string is entered to the FieldToView entry and the mvNormal, display mode is selected, the display in the PxSuperGrid component shall look like this: If the "Obec;Okres" string is entered to the FieldToView entry and the mvValueBR, display mode is selected, the display in the PxSuperGrid component shall look like this: If the "Obec;Okres" string is entered to the FieldToView entry and the mvNameAndBR, display mode is selected, the display in the PxSuperGrid component shall look like this: If the "Obec;Okres;Kraj" string is entered to the FieldToView entry and the mvNameAndBR, display mode is selected, the display in the PxSuperGrid component shall look like this: Total PxSuperGrid component display shall be as follows: But let us return to a particular programming with the PxFlyComboBox component, our example of Databank Names and Companies. To apply the AddParamFlyComboBox parameter to the wquAdresar component, it is necessary to create new PxWebQuery component, which shall be called wquObec. Add this new component to the Adresar.aspx file and the definition shall look like this:
<Prx:PxWebQuery ID="wquObec" runat="server" Value="wquObec"/>
Don't forget to define the Obec component before the wquAdresar component. Then in the Adreasar.aspx.cs file load data to the wquObec component, and then link this component to the wquAdresar component via the AddParamFlyComboBox parameter. During definition of the wquObec component, create a special SQL select, which shall combine the following three tables: Ckraj, Cokres, CObec. This SQL command shall be as follows:
select
The table resulting from this SQL command shall look like the one in the picture below: The PxFlyComboBox component can work with such table fairly well. The next image contains listing of the Adresar.aspx.cs file source code for filling data of the wquObec component and its liking to the wquAdresar component via the AddParamFlyComboBox parameter.
protected void Page_Load(object sender, EventArgs e)
If you want to use the PxFlyComboBox component for editing in the AddAdresar.aspx form, it shall be defined in this file as follows:
<Prx:PxWebQuery ID="wquObec" runat="server" Value="wquObec"/>
Link the PxFlyComboBox component to the wquAdresar component in the AddAdresar.aspx.cs file as follows:
fcmbMiesto.PxDataSource = wquAdresar;
fcmbMiesto.FieldName = "miesto";
The PxFlyComboBox component does not support alignments and AddTableRow, TableBegin TableEnd properties, which are supported by other components like PxEdit, etc. During the definition in the AddAdresar.aspx file do not forget to define besides the PxFlyComboBox component line, the wquObec component, because in other case, the PxFlyComboBox component shall not be displayed in the AddAdresar.aspx form.
<Prx:PxWebQuery ID="wquObec" runat="server" Value="wquObec"/>
If everything is set up correctly, the resulting AddAdresar.aspx form shall look like this: Titles in the Grid and captions in the PxFlyComboBox component, can be defined centrally during the definition of the wquObec component:
wquObec.Columns["IDOBEC"].Caption = "Id Municipality";
The PxFlyComboBox component contains a function through which we can find the set value of individual comboboxes. This method is called GetValue function. Description of the parameters of the GetValue function: C# syntax:
public string GetValue(string aFieldName);
Description of the parameters: FieldName - name of the column which belongs to a given combobox in the PxFlyComboBox component. Usually these are the names of the columns that were specified in the AddParamFlyComboBox parameter, namely those which have been entered into the expression aKeyFields, aKeyDetailFields or aValueFields. Example of use of the GetValue function:
string sGetVal = fcmbMiesto.GetValue("IdOkres");
In this example the GetValue function returns the value of the set district, which is set in the combobox, which is selected from a list of the districts. Here is a functional example of the PxFlyComboBox 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 |