I posting again question related to the usage of filtering of optionalDataSource in ListGrid ListGridField of which were generated automatically.
My ideas is to display several pick lists in ListGrid, one of them depends on another. Basically selection in one of them changing list in another.
My datasource is defined in XML, see below. foreignKey="AFM_FLDS2.FIELD_NAME" defines lookup list, so in automatically generated ListGridFields optionalDataSource already set (i believe), I can see pick list in my grid. But problem is I want to add filtering or criteria to this list, for example to have FIELD_NAME field to be filtered by TABLE_NAME values ( to display list of Fields which belong only to the given table name )
Under the data source XML there is a piece Java code for class which displays ListGrid
In that code I dont have access to the ListGridFields, because when the code executing those fields are not yet generated (AFAIK). So looping through the ListGridFields and setting filtering is impossible at that stage.
Also in code provided below filter pick list are always empty, even if pick list if the grid not. Question as well how to populate filters pick list. I understand I have to setFilterOptionalDataSource, but I have no access to it!!!
Please advise how to achieve the goal I'm looking for.
My ideas is to display several pick lists in ListGrid, one of them depends on another. Basically selection in one of them changing list in another.
My datasource is defined in XML, see below. foreignKey="AFM_FLDS2.FIELD_NAME" defines lookup list, so in automatically generated ListGridFields optionalDataSource already set (i believe), I can see pick list in my grid. But problem is I want to add filtering or criteria to this list, for example to have FIELD_NAME field to be filtered by TABLE_NAME values ( to display list of Fields which belong only to the given table name )
Under the data source XML there is a piece Java code for class which displays ListGrid
In that code I dont have access to the ListGridFields, because when the code executing those fields are not yet generated (AFAIK). So looping through the ListGridFields and setting filtering is impossible at that stage.
Also in code provided below filter pick list are always empty, even if pick list if the grid not. Question as well how to populate filters pick list. I understand I have to setFilterOptionalDataSource, but I have no access to it!!!
Please advise how to achieve the goal I'm looking for.
Code:
<?xml version="1.0" encoding="UTF-8"?><!-- Auto-generated from database table PDA_DATA_MATRIX --> <DataSource generatedBy="7.0rc2/SDK Development Only 2009-05-30" serverType="sql" dbName="York" dataSourceVersion="1" tableName="PDA_DATA_MATRIX" ID="PDA_DATA_MATRIX"> <fields> <field primaryKey="true" type="text" length="35" name="ROLE_NAME" foreignKey="PDA_ROLE.ROLE_NAME" required="true" /> <field primaryKey="true" type="text" length="40" name="PDA_SYNCH_NAME" foreignKey="PDA_SYNCH_RULES.PDA_SYNCH_NAME" required="true" /> <field type="text" length="32" name="TABLE_NAME" primaryKey="true" foreignKey="AFM_TBLS2.TABLE_NAME" required="true" /> <field type="text" length="32" name="FIELD_NAME" primaryKey="true" foreignKey="AFM_FLDS2.FIELD_NAME" required="true"/> <field primaryKey="true" type="text" length="32" name="PDA_FIELD_NAME" /> <field type="number" name="PRIMARY_KEY" /> <field type="number" name="DATA_TYPE" /> <field type="number" name="ALLOW_NULL" /> <field type="text" length="50" name="VALUE_AFTER_SEND" /> <field type="text" length="50" name="VALUE_AFTER_LOCK" /> <field type="text" length="40" name="SYNCH_RULE_FOR_DETAIL" /> <field type="text" length="1000" name="SQLCOMMANDIMPORT" /> <field type="text" length="1000" name="SQLCOMMAND" /> <field type="text" length="1000" name="RULE_TO_VALIDATE" /> <field type="text" length="50" name="VALUE_AFTER_UPDATE" /> <field type="number" name="ISIMPORTABLE" /> <field type="text" length="750" name="VALUE_TRANSLATION" /> <field type="text" length="32" name="FOREIGN_KEY_FIELD" /> <field type="text" length="32" name="FIELD_NAME_DEST_UPDATE" primaryKey="true" /> <field type="text" length="32" name="FIELD_NAME_DEST_INSERT" primaryKey="true" /> <field type="number" name="EXPORT_NULL" /> <field type="text" length="300" name="ERROR_MESSAGE_VALIDATION" /> <field type="text" length="300" name="ERROR_MESSAGE_NULL" /> <field type="text" length="50" name="DEFAULT_VALUE" /> <field type="number" name="ISEXPORTABLE" /> </fields> </DataSource>
Code:
final DataSource ds = DataSource.get(dbName); DataSourceField[] dsf = ds.getFields(); for (int i = 0; i < dsf.length - 1; i++) { DataSourceField ff = dsf[i]; if (ff.getAttribute("foreignKey") != null) { ComboBoxItem cb = new ComboBoxItem(); if(ff.getName() == "FIELD_NAME") cb.setCriteriaField("TABLE_NAME"); ff.setEditorType(cb); } } final ListGrid listGrid = new ListGrid(); listGrid.setDataSource(ds); listGrid.setUseAllDataSourceFields(true); listGrid.setHeight100(); listGrid.setWidth100(); listGrid.setShowFilterEditor(true); listGrid.setShowRecordComponents(true); listGrid.setAlternateRecordStyles(true); listGrid.setShowAllRecords(true); listGrid.setCanEdit(true); listGrid.setAutoFetchData(false); listGrid.fetchData();