Jump to content


Photo

NextGrid6: Selected Row issues


  • Please log in to reply
3 replies to this topic

#1 BelangerC

BelangerC

    Senior Member

  • Members
  • PipPip
  • 221 posts
  • Location:Richmond, CA USA
  • Interests:Alternative medicine, programming for

Posted 22 July 2018 - 08:30 PM

Hi, Boki:

 

I have added a new grid to my project (not a converted NG5 grid). It is a simple non-treed grid that lists users. It is loaded from a database. On selection of a user in the grid, the dataset is LOCATED and that in turn displays a more complete series of DB related components and fills them (wwRecordPanel, wwDBEdit, etc).

 

If I use a mouse click to select a row, all is well, but if I use the events in a Navigator Bar (next, prior, top, bottom), the row is moved and scrolled to, but the row is not selected visually with the selected row settings, nor is the indicator visible for the selected row.

 

What appears to be true is that setting Row[x].Selected := true does not:

1. Fire the OnSelect Event

2. Set the Selected Row settings (full row, selected text color, selected row color)

3. Does not display the Indicator for the programmatically selected row, which otherwise is shown when using the mouse click.

 

Am I missing something here to make this work as expected?

 

Thank you,

Chuck

p.s. in Delphi 10.2.1, Win10

 

Here is my code for going to the top row:

 

 if Button = nbFirst then
  begin
 
    with gridTVUsers do
    begin
      Row[0].Selected := True;
      ScrollToTop;
 
      UserID := Cell[NxNumberUserID.Index, 0].AsInteger;
 
      qryUsers.Locate('USER_ID', UserID, []);
    end;
  end;
 
Here is my code for going to the next row:
 
else if Button = nbNext then
  begin
    with gridTVUsers do
    begin
      if RowExists(SelectedRow + 1) then
      begin
        ActiveView.ScrollToRow(SelectedRow + 1);
        Row[SelectedRow + 1].Selected := true;
 
        UserID := Cell[NxNumberUserID.Index, SelectedRow].AsInteger;
 
        qryUsers.Locate('USER_ID', UserID, []);
      end;
    end;
  end

 

Here is my OnSelect event:

 

 with gridTVUsers do
  begin
    UserID := Cell[NxNumberUserID.Index, ARow].AsInteger;
    // before moving off record, post any changes
    if qryUsers.State in [dsEdit, dsInsert] then
    begin
      qryUsers.Post;
      qryUsers.IB_Transaction.Commit;
    end;
    qryUsers.Locate('USER_ID', UserID, []);
  end;
 
  FillAccessGroups(qryUsers.FieldByName('group_access').asString,
    clbxNMTAttendence);
 
  FillCPUID_RegDate(qryUsers.FieldByName('CPUID_REGISTRATION_Date').AsInteger,
    dtpCPUID_RegDate); // here, below
 
 
  // 8/19/16 set radio group status... Fields below are now boolean, not 0/1
  rgPurchasePlan.ItemIndex := StrToInt(IIF(qryUsers.FieldByName('SYSTEM_SUBSCRIPTION')
    .AsString= 'TRUE','1','0'));
  rgSupportPlan.ItemIndex := StrToInt(IIF(qryUsers.FieldByName('SUPPORT_SUBSCRIPTION')
    .AsString = 'TRUE','1','0'));


#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 22 July 2018 - 08:51 PM

Hi,

My first guess is that maybe you need to set HideSelection property to False?
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 22 July 2018 - 09:25 PM

PS. I also suggest that you just set SelectedRow := Value instead Selected property of Row. Selected is used more for Multi-select.
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#4 BelangerC

BelangerC

    Senior Member

  • Members
  • PipPip
  • 221 posts
  • Location:Richmond, CA USA
  • Interests:Alternative medicine, programming for

Posted 23 July 2018 - 05:01 AM

Thank you, Boki.

 

Turns out I had HideSelection := false;

But, using SelectedRow := x, worked. Nice to know about the difference between Row[x].Selected and SelectedRow.

Chuck






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users