Jump to content


Photo

NextGrid v6 API clarifications

design application architecture

  • Please log in to reply
4 replies to this topic

#1 Yoni

Yoni
  • Members
  • 2 posts
  • Gender:Male

Posted 22 January 2019 - 03:58 PM

I've a data source which I fetch data from in asynchronous way (100 rows each time up to 10,000 rows) The data arrives as XML so I parse and convert it to my internal data structure (let us assume this is a TList<TMyData> )

 

I would like to show the data in the gird as it arrives (I don't want to wait until I first fetch all the data). 

 

My understanding from the documentation is that I need to add to the grid the number of new rows that arrives each time and then set each cell with the with values. Am I right?  

 

Aside from that the documentation wasn't clear about couple more subjects:

1. When I set the cells values? 

2. How do I bind a row in the grid to the my own data source (TList<TMyData> ) so that when the user clicks on a row I'll know which TMyData was selected. 

 

 

Thanks, 

Yoni



#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 22 January 2019 - 05:35 PM

Hello Yoni,

You can set data by using Cell property. Example:

NextGrid61.Cell[x, y].AsString := 'string value'; // or AsInteger, AsFloat

1) I suggest that you call BeginUpdate, then add rows and set cells and then call EndUpdate.

2) You can use SelectedRow integer property. This will give you index at any time.

Hope this helps a little bit.
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 AlexMex

AlexMex
  • Members
  • 19 posts

Posted 22 January 2019 - 08:36 PM

For point two, I prefer to store record Id in an invisible column or point the data property of the row to some object (the TMyData instance in your case)



#4 Boki (Berg)

Boki (Berg)

    Boki (Berg)

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

Posted 23 January 2019 - 12:34 AM

Hi,

You can do it then in next way:

RowId := NextGrid61.Cell[MyHiddenCol.Index, NextGrid61.SelectedRow].AsInteger;
// Do something with RowId
One other solution is to attach reference to your object to Data property of cell. Event row (NextGrid61.Row[x].Data...) have Data property.
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.

#5 Yoni

Yoni
  • Members
  • 2 posts
  • Gender:Male

Posted 27 January 2019 - 11:32 AM

Thanks

 

So let me see if  I got it right (pseudo code):

 

grid.BeginUpdate

 

for every new MyData in the list:
  row := grid.AddRow()

  row[0] := MyData.prop1

  row[1] := MyData.prop2

  ....

  row.Data := MyData

end

 

grid.EndUpdate

 

?






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users