views:

23

answers:

1

i'm just struggling through the following situation - there's a datasource added to a grid in axapta 2009, filtered by a querybuildrange.

i want to mark a specific dataset by x++ via

datasource_DS.findrecord( specificRecord )

this works as intended, removing the filter, but not having the filter active! a workaround to remove the filter and add everything ( filtered! )to a temporary table first is not what i want.

i can't imagine there's no way to achieve this task?! thanks in advance!

edit:

datasources on form: - ProdRouteJob ( JoinSource: ProdTable, LinkType: InnerJoin ) - ProdTable

only datasets containing a specified ProdStatus should be displayed in the grid. This is done by the mentioned Range, e.g.:

prodStatusRange =  prodTable_ds.query().dataSourceTable( tablenum( ProdTable )).addRange( fieldnum( ProdTable, ProdStatus ));
prodStatusRange.value( "(( ProdStatus == 0) || ( ProdStatus == 1 ))" );

selecting a specified dataset is done by, e.g.:

ProdRouteJob currentProdRouteJob;
;
currentProdRouteJob = ProdRouteJob::findJobId( "JOB_12345" );
info ( currentProdRouteJob.JobId );
prodRouteJob_DS.findRecord( currentProdRouteJob );

the info-function shows the correct JobId. if i remove the filter, findRecord() selects the dataset, if not - not. adding the DS.research( true ); does not change this behaviour.

A: 

You objective is to redraw the grid and to retain any filtering.

In AX 2009 it is easy:

datasource_DS.research(true);

In AX 4.0 and previous you can research and then refind:

specificRecord = datasource.data();
datasource_DS.research();
datasource_DS.findRecord(specificRecord) 

This can sometimes be slow if there are many records in the grid.

Jan B. Kjeldsen
whether i'm using your suggested code or not, the behaviour is the same. the specified dataset is not selected. maybe, there's a mistake at my side. i'll post the code below.
Nico
Try to simplify your range expression as: `prodStatusRange.value("0,1");`Also after the change of the range a `ds.executeQuery()` must run.A `ds.executeQuery()` or `ds.research()` must precede the `findRecord` for it to be effective.
Jan B. Kjeldsen