SmartClient Version: v8.2p_2012-10-02/PowerEdition Deployment (built 2012-10-02)
and
SmartClient Version: v8.3p_2013-01-04/PowerEdition Deployment (built 2013-01-04)
and
SmartClient Version: v8.3p_2013-01-13/PowerEdition Deployment (built 2013-01-13)
Chrome 24.0.1312.52
I have a list grid bound to a datasource which has several foreign keys (to differente tables):
I have a form to select and filter the grid on one of those foreign keys:
the selection is observed by a grid which is bounded to the above datasource. On execution of observed method the 'updateFilterStagioneCorrente' gets called (this is modelled after the click method of the orderItemCriteriaForm in the #dynamicReporting sample)
everything works when the grid filter is empty or filtered on non-foreign keys fields.
If I filter on a foreign key field, then when I change the form select, the combineCriteria in the 'updateFilterStagioneCorrente' is incorrect and the filter of the grid gets lost.
you can see the generated criteria in the server side logs.
This is correct, when I filter for the foreign key field in the grid filter
this is incorrect, when, right after, I change the select in the form
the latter log is with 8.2 version. 8.3 gives a different log:
with the chrome inspector, I can see the grid criteria (https://www.evernote.com/shard/s282/...81af3db4581639), the form criteria converted in an AdvancedCriteria (https://www.evernote.com/shard/s282/...f94baeca90c3e7), and then the combined criteria https://www.evernote.com/shard/s282/...d52553a70ecd84.
If you could point me to a sample with a datasource with two foreign keys to different tables, I can try to make a standalone sample in the showcase
and
SmartClient Version: v8.3p_2013-01-04/PowerEdition Deployment (built 2013-01-04)
and
SmartClient Version: v8.3p_2013-01-13/PowerEdition Deployment (built 2013-01-13)
Chrome 24.0.1312.52
I have a list grid bound to a datasource which has several foreign keys (to differente tables):
Code:
<DataSource ID="JPC_CONTRATTI" tableName="JPC_CONTRATTI" schema="DBSALES" dbName="dbJpcEP" serverType="sql" dropExtraFields="false" > <fields> <field sqlType="decimal" primaryKey="true" name="ID_REC" type="sequence" hidden="true"> <sequenceName>SEQUENCE_ID_REC</sequenceName> </field> <field foreignKey="JPC_STAGIONI.ID_REC" sqlType="decimal" sqlLength="0" name="ID_STAGIONI_FK" type="integer" optionDataSource="JPC_STAGIONI" valueField="ID_REC" displayField="DESCRIZIONE"> </field> <field name="STAGIONE" type="text" tableName="JPC_STAGIONI" nativeName="DESCRIZIONE"/> <field sqlType="decimal" sqlLength="0" name="CONTRATTO_NUM" type="integer"> </field> <field foreignKey="JPC_ANAGRAFICA_CLIENTI.ID_REC" sqlType="decimal" sqlLength="0" type="integer" name="ID_ANAGRAFICA_CLIENTI_FK" displayField="SOGGETTO_DESC"> </field> <field name="TIPO_SOGGETTO" type="text" tableName="JPC_TIPI_SOGGETTO" nativeName="DESCRIZIONE"> </field> <field name="SOGGETTO_DESC" type="text" customSelectExpression="decode(JPC_TIPI_SOGGETTO.CODICE, 'AZ', JPC_ANAGRAFICA_CLIENTI.SOGGETTO_DESC, JPC_ANAGRAFICA_CLIENTI.COGNOME || ' ' || JPC_ANAGRAFICA_CLIENTI.NOME)"/> <field foreignKey="JPC_STATI_CONTRATTO.ID_REC" sqlType="decimal" sqlLength="0" type="integer" name="ID_STATO_CONTRATTO_FK" displayField="CODICE"> </field> <field foreignKey="JPC_CONTRATTI.ID_REC" sqlType="decimal" sqlLength="0" type="integer" name="ID_CONTRATTO_PRECEDENTE_FK"></field> <field name="CONTRATTO_NUM_PRECEDENTE" type="integer" customSelectExpression="(select a.CONTRATTO_NUM from JPC_CONTRATTI a where JPC_CONTRATTI.ID_CONTRATTO_PRECEDENTE_FK = a.ID_REC)"> </field> <field sqlType="decimal" name="ID_NOTE_INTERNE_FK" type="integer" foreignKey="JPC_NOTE.ID_REC"> </field> </fields> <operationBindings> <operationBinding operationType="fetch"> <tableClause>$defaultTableClause, JPC_CONTRATTI_RIGHE, JPC_VOCI_DI_LISTINO, JPC_STATI_CONTRATTO, JPC_STAGIONI, JPC_ANAGRAFICA_CLIENTI, JPC_TIPI_SOGGETTO</tableClause> <whereClause> $defaultWhereClause and JPC_ANAGRAFICA_CLIENTI.ID_REC = JPC_CONTRATTI.ID_ANAGRAFICA_CLIENTI_FK and JPC_ANAGRAFICA_CLIENTI.ID_TIPI_SOGGETTO_FK = JPC_TIPI_SOGGETTO.ID_REC and JPC_CONTRATTI_RIGHE.ID_VOCE_LISTINO_PER_SCONTO_FK = JPC_VOCI_DI_LISTINO.ID_REC(+) and JPC_CONTRATTI.ID_REC = JPC_CONTRATTI_RIGHE.ID_CONTRATTI_FK(+) and JPC_CONTRATTI.ID_STATO_CONTRATTO_FK = JPC_STATI_CONTRATTO.ID_REC(+) and JPC_CONTRATTI.ID_STAGIONI_FK = JPC_STAGIONI.ID_REC(+) </whereClause> </operationBinding> </operationBindings> </DataSource>
Code:
isc.DynamicForm.create({ ID:"sceltaStagioneCorrenteForm", getStagioneCorrente:function () { return this.getValue('ID_STAGIONI_FK') || this.getStagioneCorrenteOffline(); }, setStagioneCorrente:function (idStagione) { this.setValue('ID_STAGIONI_FK', idStagione); }, fetchStagioneCorrente:function (callback, dsRequestProperties) { var advancedCriteria = { _constructor:"AdvancedCriteria", operator:"and", criteria:[ { fieldName:"DATA_INIZIO", operator:"lessOrEqual", value:new Date() }, { fieldName:"DATA_FINE", operator:"greaterOrEqual", value:new Date() } ] }; JPC_STAGIONI.fetchData( advancedCriteria, callback, dsRequestProperties ); }, aggiornaStagioneCorrenteOffline:function (idStagioneFk) { isc.Offline.put('jpcep.stagioneCorrenteId', idStagioneFk); }, dataFetchMode:"basic", getStagioneCorrenteOffline:function () { return isc.eval(isc.Offline.get('jpcep.stagioneCorrenteId')); }, items:[ { name:"ID_STAGIONI_FK", type:"select", optionDataSource:"JPC_STAGIONI", optionCriteria:{fieldName:"DESCRIZIONE", operator:"notEqual", value:'2011/2012'}, displayField:"DESCRIZIONE", valueField:"ID_REC", width:100, defaultDynamicValue:function (item, form, values) { var idStagioneCorrente = form.getStagioneCorrenteOffline(); if (!idStagioneCorrente) { form.fetchStagioneCorrente( function (dsResponse, data, dsRequest) { if (data && data[0]) { dsRequest.form.aggiornaStagioneCorrenteOffline(data[0].ID_REC); dsRequest.form.setStagioneCorrente(data[0].ID_REC); } }, {form:form} ); } return idStagioneCorrente; }, title:i18nMessages.gestioneContratti + ' - ' + i18nMessages.sceltaStagione, titleStyle:"formTitleInSectionControls", changed:function (form, item, value) { form.aggiornaStagioneCorrenteOffline(value); } } ] });
Code:
isc.ListGrid.create({ ID:"elencoContrattiGrid", dataSource:"JPC_CONTRATTI", height:"60%", selectionType:"single", initialSort:[ {property:"CONTRATTO_NUM", direction:"ascending"} ], hoverWidth:200, initialCriteria:{ _constructor:"AdvancedCriteria", operator:"and", criteria:[ { fieldName:"ID_STAGIONI_FK", operator:"equals", value:sceltaStagioneCorrenteForm.getStagioneCorrente() } ] }, initWidget:function () { this.Super("initWidget", arguments); this.observe(sceltaStagioneCorrenteForm, 'aggiornaStagioneCorrenteOffline', "observer.updateFilterStagioneCorrente()") }, updateFilterStagioneCorrente:function () { var criteria = this.getFilterEditorCriteria(true); if (!criteria) criteria = {}; var formCriteria = isc.DataSource.convertCriteria(sceltaStagioneCorrenteForm.getValuesAsCriteria()); criteria = isc.DataSource.combineCriteria(criteria, formCriteria); this.invalidateCache(); this.filterData(criteria); } })
If I filter on a foreign key field, then when I change the form select, the combineCriteria in the 'updateFilterStagioneCorrente' is incorrect and the filter of the grid gets lost.
you can see the generated criteria in the server side logs.
This is correct, when I filter for the foreign key field in the grid filter
Code:
2013-01-14 11:13:23,440 DEBUG RPCManager Request #1 (DSRequest) payload: { criteria:{ _constructor:"AdvancedCriteria", operator:"and", criteria:[ { fieldName:"ID_STAGIONI_FK", operator:"equals", value:1183260 }, { fieldName:"ID_ANAGRAFICA_CLIENTI_FK", operator:"equals", value:170721 } ] }, operationConfig:{ dataSource:"JPC_CONTRATTI", operationType:"fetch", textMatchStyle:"substring" }, startRow:0, endRow:75, sortBy:[ "CONTRATTO_NUM" ], componentId:"elencoContrattiGrid", appID:"builtinApplication", operation:"JPC_CONTRATTI_fetch", oldValues:{ _constructor:"AdvancedCriteria", operator:"and", criteria:[ { fieldName:"ID_STAGIONI_FK", operator:"equals", value:1183260 }, { fieldName:"ID_ANAGRAFICA_CLIENTI_FK", operator:"equals", value:170721 } ] } }
Code:
2013-01-14 11:16:01,073 DEBUG RPCManager Request #1 (DSRequest) payload: { criteria:{ operator:"and", _constructor:"AdvancedCriteria", criteria:[ { fieldName:"operator", operator:"iContains", value:"and" }, { _constructor:"AdvancedCriteria", operator:"or", criteria:[ { fieldName:"criteria", operator:"iContains", value:{ fieldName:"SOGGETTO_DESC", operator:"iContains", value:"Balocco" } } ] }, { fieldName:"ID_STAGIONI_FK", operator:"equals", value:146969 } ] }, operationConfig:{ dataSource:"JPC_CONTRATTI", operationType:"fetch", textMatchStyle:"substring" }, startRow:0, endRow:75, sortBy:[ "CONTRATTO_NUM" ], componentId:"elencoContrattiGrid", appID:"builtinApplication", operation:"JPC_CONTRATTI_fetch", oldValues:{ operator:"and", _constructor:"AdvancedCriteria", criteria:[ { fieldName:"operator", operator:"iContains", value:"and" }, { _constructor:"AdvancedCriteria", operator:"or", criteria:[ { fieldName:"criteria", operator:"iContains", value:{ fieldName:"SOGGETTO_DESC", operator:"iContains", value:"Balocco" } } ] }, { fieldName:"ID_STAGIONI_FK", operator:"equals", value:146969 } ] } }
Code:
2013-01-14 11:21:34,771 DEBUG RPCManager Request #1 (DSRequest) payload: { criteria:{ operator:"and", _constructor:"AdvancedCriteria", criteria:[ { fieldName:"operator", operator:"iContains", value:"and" }, { _constructor:"AdvancedCriteria", operator:"or", criteria:[ { fieldName:"criteria", operator:"iContains", value:{ fieldName:"ID_ANAGRAFICA_CLIENTI_FK", operator:"equals", value:170721 } } ] }, { fieldName:"ID_STAGIONI_FK", operator:"equals", value:1183260 } ] }, operationConfig:{ dataSource:"JPC_CONTRATTI", operationType:"fetch", textMatchStyle:"substring" }, startRow:0, endRow:75, sortBy:[ "CONTRATTO_NUM" ], componentId:"elencoContrattiGrid", appID:"builtinApplication", operation:"JPC_CONTRATTI_fetch", oldValues:{ operator:"and", _constructor:"AdvancedCriteria", criteria:[ { fieldName:"operator", operator:"iContains", value:"and" }, { _constructor:"AdvancedCriteria", operator:"or", criteria:[ { fieldName:"criteria", operator:"iContains", value:{ fieldName:"ID_ANAGRAFICA_CLIENTI_FK", operator:"equals", value:170721 } } ] }, { fieldName:"ID_STAGIONI_FK", operator:"equals", value:1183260 } ] } }
If you could point me to a sample with a datasource with two foreign keys to different tables, I can try to make a standalone sample in the showcase
Comment