Options

Go to specific line in grid

MortenSteengaardMortenSteengaard Member Posts: 131
edited 2023-01-03 in Dynamics AX
Hi experts,

In Axapta 4.0, I have a grid with lines/records. The user can create records and change field values. When a field is modified, the form must change values on the current record and on some other records in the same form. And then it must refresh itself.

It works fine, except that when all that is done (from method modified() on the datasource field), then the form is refreshed and the focus jumps to the topmost record. (So for instance, when the user creates a record and enters 3 fields, then as the next field is modified, the cursor is suddenly on one of the old records and the new record is at the bottom of the grid.)

In order to simplify this, I have created a new table and a new form.

On the forms' classDeclaration, I have written this:
myTable myTableLocal;

On one of the form's datasource field, I have written this:
public void modified()
{
    ;
    
    super();

    myTable_DS.write();

    myTableLocal = myTable.data();

    myTable_DS.research();    // research and refresh are called from within the methods, my real program calls
    myTable_DS.refresh();
   
    if (myTableLocal.RecId)
    {
        myTable_DS.findRecord(myTableLocal);
    }
}

On the form's datasource, I have made this method:
public void executeQuery()
{
    ;
    
    super();
    
    if (myTableLocal.RecId)
    {
        myTable_DS.findRecord(myTableLocal);    // just a test
    }
}

it works if I hard code it in executeQuery, but when it go through modified, it forgets that I have called findRecord.

I really hope, you can help!
Sign In or Register to comment.