How to select particular line in a grid control?

sandosando Member Posts: 3
edited 2006-07-08 in Dynamics AX
Hello,

i would like to select one particular line in a grid control. I have following code at end of the write method of smmBusRelTable data source.
... 
//copy current line to buffer
_smmBusRelTable = smmBusRelTable;

//and execute query
//after this i am on another line in a grid control
this.executeQuery();

//i try to jump to the old line
this.markRecord(_smmBusRelTable);

Best regards,
Sando

Comments

  • sandosando Member Posts: 3
    My friend has already helped me to solve the problem.
    Below is correct code
    ....
    //copy primary key of current line to buffer
    smmAccount = smmBusRelTable.BusRelAccount;
    
    //and execute query
    //after this i am on another line in a grid control 
    this.executeQuery();
    
    //and now jump to the old line    
    this.findRecord(SmmBusRelTable::find(smmAccount));
    this.refresh();
    
  • kashperukkashperuk Member Posts: 53
    And now to explain you the reason:

    When you assinged the value of one table variable to the other, you did not copy the data to the new table variable, but simply pointer it to the same cursor as the first one.

    And, of course, after the cursor was changed, both table variables pointed to the new cursor, and not the one you were trying to save.

    To avoid this, you could save the key field instead, (that's what you did) or, you could use the special method data() to copy the value of the cursor, like the following:

    _smmBusRelTable.data(smmBusRelTable);
    Vanya Kashperuk,
    My blog - http://kashperuk.blogspot.com
    MorphX IT in Russian - http://www.lulu.com/content/723888
    Inside Dynamics AX 4.0 in Russian - http://www.ozon.ru/context/detail/id/3714582
Sign In or Register to comment.