Jump to content


Photo

Treeview Column, use of LastAddedRow


  • Please log in to reply
1 reply to this topic

#1 BelangerC

BelangerC

    Senior Member

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

Posted 02 August 2021 - 11:14 PM

Hi, Boki:

Coming from NxGrid5 (still not confident about moving my code over) and doing a new form with a new NextGrid, thus using NextGrid6 and in that a Treed Column.

 

Basically trying to do the following with a dataset to load the grid, the LastAddedRow is not correct when AddChildRow;

 

How do I do this with the new NextGrid6?

 

Thank you,

Chuck

p.s. I posted an issue in NextGrid5 and would really like your feedback, i.e. is the issue corrected in NextGrid6? You said you would have a fix about a year ago. Were you able to do so? Regards Autoupdate of list column cells which require enter or clicking onto another cell in grid otherwise the cell acts as though no value was entered. Thank you!

 

with gridClientSessions do
begin
 while not EOF do
 begin
 PRID := FieldByName('pr_id').AsInteger;
 AddRow();
 LastPRRow :=  LastAddedRow;
 Cell[NxTreeColumn61.Index, LastAddedRow].AsString := FieldByName('prname').AsString;
 
 while not Eof and (PRID = FieldByName('pr_id').AsInteger) do
 begin
  PTID :=FieldByName('pt_id').AsInteger;
 // LastPTRow := AddChildRow(LastPRRow).GetIndex; <== this does not give the correct row index added.
 LastPTRow := LastAddedRow;  //this is not correct!  <== 
 
  Cell[NxTreeColumn61.Index,LastAddedRow].AsString := FieldByName('Client_Name').AsString;
 
  while not Eof and (PTID = FieldByName('pt_id').AsInteger) do
  begin
  // LastSesRow := AddChildRow(LastPTRow).GetIndex;
LastPTRow := LastAddedRow; // incorrect row value
  AddChildRow(LastPTRow);
   Cell[NxTreeColumn61.Index, LastAddedRow].AsString := 'Session Number: ' + FieldByName('ses_number').AsString;
  Next;
  end;//same PTID patient ID
 
 end; //Same PRID practitioner ID
 
 end; //not eof
 


#2 BelangerC

BelangerC

    Senior Member

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

Posted 03 August 2021 - 02:37 AM

I was able to figure this out on my own:

 

The trick is using the AbsoluteIndex of AddRow().

 

Thank you,

Chuck

p.s. Still would like a reply to my post in NextGrid5. Thank you!

 

with gridClientSessions do
begin
 while not EOF do
 begin
 PRID := FieldByName('pr_id').AsInteger;
 LastPRRow := AddRow().AbsoluteIndex;
 
 Cell[NxTreeColumn61.Index, LastPRRow].AsString := FieldByName('prname').AsString;
 
 while not Eof and (PRID = FieldByName('pr_id').AsInteger) do
 begin
  PTID :=FieldByName('pt_id').AsInteger;
  LastPTRow := AddChildRow(LastPRRow).AbsoluteIndex;
 
  Cell[NxTreeColumn61.Index,LastPTRow].AsString := FieldByName('Client_Name').AsString;
  while not Eof and (PTID = FieldByName('pt_id').AsInteger) do
  begin
   LastSesRow := AddChildRow(LastPTRow).AbsoluteIndex;
   Cell[NxTreeColumn61.Index, LastSesRow].AsString := 'Session Number: ' + FieldByName('ses_number').AsString;
  Next;
  end;//same PTID
 
 
 end; //Same PRID
 
 end; //not eof
 
end;





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users