Jump to content

Mobile DBListGrid scroll selected row into view via code


andyhill

Recommended Posts

1 hour ago, andyhill said:

Grid has 500 records

Records 1 to 30 are displayed

In code we use table.locate record 300 

Record 300 is selected BUT out of view

 Scroll selected row into view via code

Try this approach, for example:

procedure TMainmForm.UnimButton1Click(Sender: TObject);
begin
  with UniMainModule do
  begin
    DataSource1.DataSet.Locate('Species No', 90130, [loPartialKey]);
    UnimDBListGrid1.JSInterface.JSCallDefer('ensureVisible', [JSInterface.JSStatement(UnimDBListGrid1.JSName + '.getLastSelected()')], 50);
  end;
end;

 

Link to comment
Share on other sites

Thank you Sherzod, the selected record is now the last visible row in the grid :)

What if we wanted to see this record in the middle of the visible rows

eg.

records 285 to 315 are now visible records in the grid, can we get our selected record 300 to display in the middle of the current visible rows ?

 

 

Link to comment
Share on other sites

53 minutes ago, andyhill said:

What if we wanted to see this record in the middle of the visible rows

Try this approach:

procedure TMainmForm.UnimButton1Click(Sender: TObject);
begin
  with UniMainModule do
  begin
    DataSource1.DataSet.Locate('Species No', 90170, [loPartialKey]);
    UnimDBListGrid1.JSInterface.JSCode('Ext.defer(function(){'#1'.element.select(".x-selected").elements[0].scrollIntoView({block: "center", behavior: "smooth"})}, 50);'); //<---------
  end;
end;

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...