Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cursor moves to top when refreshing list page grid

Fellow developers, I have a custom list page, where a user can select few records, hit a button in Action pane that runs some logic in a class, and all that works fine. My problem is that the cursor does not stay at the same record but goes to the top of the grid. Sounds like a familiar issue?

I store the FormDataSource of the list page using args in the custom class that has all the logic.

I tried few things but none worked.

  1. formDataSource.research(true) True parameter is supposed to retain the position after research does its job. I am guessing this should have been the most straightforward solution. List page query has 2 datasources joined using Outer join and my guess is research(true) works only with Inner joins.

  2. formDatasource.setPosition(position)

    int position;
    position = formDatasource.getPosition();

    formDatasource.research();

    formDatasource.setPosition(position);

    I store the position using getPosition and set it again using setPosition. No use.

  3. formDataSource.findRecord()

    currentRecord = formDatasource.cursor();

    recId = currentRecord.RecId;
    formDatasource.reread();

    formDatasource.research();
    formDatasource.findRecord(currentRecord);

    i use the ds.cursor() to get the current record and pass it to findRecord() after research(). No use.

  4. formDataSource.findValue()

    currentRecord = formDatasource.cursor();

    recId = currentRecord.RecId;
    formDatasource.reread();

    formDatasource.research();
    formDatasource.findValue(fieldNum(Table, RecId), int642str(recId));

    i use the ds.cursor() to get the current record and recId and pass it to findValue() after research(). No use.

I debugged the above code and the cursor() method does get the current record and its recId. I have started to believe that it might be a limitation of list page, and praying that somebody proves me wrong.

Any help is appreciated.

like image 857
Harry Avatar asked Nov 03 '22 18:11

Harry


1 Answers

Use Method 3 but like this.

YourTable tmpTable;


currentRecord = formDatasource.cursor();

recId = currentRecord.RecId;
tmpTable = TmpTable::findByRecId(recId);
 formDatasource.reread();

formDatasource.research();
formDatasource.findRecord(tmpTable); 

Hope this helps.

like image 86
Jes Gudiksen Avatar answered Jan 04 '23 13:01

Jes Gudiksen