mbalsam
2017-11-29T22:38:10Z
Hi,

We've recently started using iGrid and have two questions.

1) We understand there is no support for a Virtual Mode as one of your forum users put and very limited support for loading from a data source. But what we want to do is something a bit different:

We want to do is support paging of data into the control from our database. We would start off by loading 100 rows and wait for an event that says, Your X rows from the bottom of your 100 rows, reload more data to the bottom of the list now.

We want this because our goal is to be able to display the control as quickly as possible.

We believe this would be possible if we had a few events that could be subscribed to.

We understand there are events that tell us, that the window is scrolled down or up. So, it might just be an extension of these existing events.

Does this makes sense, is there a better way?

2) If #1 is not possible, another way would be to subscribe to the scroll up and down vents and check line is visible. This would tell us where close to the bottom or top etc. Is there any easy way to accomplish this?

3) We are willing to do some library hacking to make this work.

Thoughts??
Igor/10Tec
2017-11-30T14:52:14Z
Yes, iGrid.NET does not implement a virtual mode, but it provides you with an event that can be used for that. This is the CellDynamicContents event. This event is raised for every cell that appears in the viewport of iGrid when iGrid draws them, and you can specify the text in a cell on-the-fly. The key point is that this event is raised only for the cells that become visible for the user, so it may be even better than paging you are thinking about.

To make it work, define the columns and all rows you need but do not populate cell values. Instead, set them on-the-fly in an event handler of the CellDynamicContents event.

If this approach does not work for you, you can try to harness the scroll bar events like VScrollBarValueChanging/VScrollBarValueChanged to implement what you need.

Perhaps, if you provide more info about your grid, we can help you more. If possible, share some screenshots.
mbalsam
2017-11-30T15:01:45Z
So, find out the total number of rows in the dataset. Create an empty row for each one. Populate the control with one page of data. In the callback handler, check if the current row is an empty one. if so hit the db and bring in more rows? Is that the basic idea?
Igor/10Tec
2017-11-30T16:52:03Z
You just create the required number of rows in iGrid with one simple call, for example:

iGrid1.Rows.Count = 100000

Then you simply access rows in your db from the CellDynamicContents event handler. You will access only the rows that are visible on the screen. If the grid can display say 22 rows in the viewport, only those rows will be accessed. You even will not need to access say 100 rows if you planned to page iGrid by 100 rows.

Perhaps, we are talking about different things. Perhaps, your db does not allow random access to rows (for instance, if you use so called forward-only recordsets or ADO.NET data readers that can read records only in one direction).

Give us more details about your project so we can be more helpful.
mbalsam
2017-11-30T17:18:10Z
Thanks. I think your suggestion will work perfectly!

I do have a few other questions:

1) We're making use of your ability to make the grid look like an "outlook" like control. Is there a way to change the row highlight on mouse over events?

2) For the row.RowTextCell value, is there a way to dynamically set the style of each row, so that color, font and font size is different than the text on the container cell but also different for each row in the grid. We need to show different colors for each row depending on the data we are displaying but it looks like it is not possible to change each row individually

I'm looking for something like CellDynamicFormatting but for the RowTextCell section

I tried doing this on the handler for CellDynamicFormatting but it looks like it ignores the values on that style, i want the second line to show a different color but only on some special cases

row.RowTextCell.Style = new iGCellStyle()
{
ForeColor = MyCustomRowTextColor,
Font = MyCustomOutlookFont
};
mbalsam
2017-11-30T22:23:52Z
3) With the outlook messages list emulation, how do you change the color of the bar that separates rows. Currently its black, in outlook its light grey.
juanMH
2017-12-01T00:11:34Z
Originally Posted by: Igor/10Tec 

You just create the required number of rows in iGrid with one simple call, for example:

iGrid1.Rows.Count = 100000

Then you simply access rows in your db from the CellDynamicContents event handler. You will access only the rows that are visible on the screen. If the grid can display say 22 rows in the viewport, only those rows will be accessed. You even will not need to access say 100 rows if you planned to page iGrid by 100 rows.

Perhaps, we are talking about different things. Perhaps, your db does not allow random access to rows (for instance, if you use so called forward-only recordsets or ADO.NET data readers that can read records only in one direction).

Give us more details about your project so we can be more helpful.



Hi, i implemented the paging support in a different way, only have a couple questions/comments

1. The CellDynamicContents event handler is called every time the row is on the screen, even if nothing has changed, this resulted in slow performance since i had to process every row more than once, is this the expected behavior, that it redraws the row every time it is on the screen and while scrolling?

2. Is it possible to programmatically reload a single row so that i can update images on columns or change the font style or color? I looked into this but it looks like there's no way to request a single row refresh or update in place, without having to rely on other events like scrolling or the CellDynamicContents event handler, since it will not be triggered if something happened behind the scenes on my backend.

3. Finally, i noticed that when i load another set of rows into the screen, i would get the CellDynamicContents event handler called for the new last row even if it was not on the screen at the time. For example say i had 100 rows, i add another 100, then i get the event handler calling me with e.RowIndex == 199, but that row is not on the screen or even close, the grid seems to somehow still request the data for that row, which confuses my code since it believes we have scrolled to the end of the grid again. Is there a way around this? Is this a known effect or maybe i'm understanding wrong how the CellDynamicContents feature works? i thought it would only be called for items currently being displayed on the screen, like if i have a 100 rows but only 10 are visible only those get called and if i add another 100 no event handler for CellDynamicContents will be called because the new rows are not on the screen at all?

Thanks for your quick answers and help

Regards
Igor/10Tec
2017-12-01T12:47:32Z
Originally Posted by: mbalsam 

1) We're making use of your ability to make the grid look like an "outlook" like control. Is there a way to change the row highlight on mouse over events?



Try to use the CellMouseEnter event for that. The e.RowIndex argument of the event contains the index of the row under the mouse pointer. If it has changed, make the new row under the mouse pointer current. You can use the SetCurRow method for that.

Originally Posted by: mbalsam 

I'm looking for something like CellDynamicFormatting but for the RowTextCell section



The purpose of the CellDynamicFormatting event is to provide formatting for a cell dynamically, but you must not change the cell's style in an event handler of this event. Look at the sample from the help:

private void iGrid1_CellDynamicFormatting(
  object sender, iGCellDynamicFormattingEventArgs e)
{
  if((int)iGrid1.Cells[e.RowIndex, "Price"].Value > 10)
    e.BackColor = Color.BackRed;
}

You specify the required formatting through the properties of the 'e' parameter of the event.
Igor/10Tec
2017-12-01T13:09:22Z
Originally Posted by: mbalsam 

3) With the outlook messages list emulation, how do you change the color of the bar that separates rows. Currently its black, in outlook its light grey.



I think we are talking about horizontal grid lines. To configure them, use the iGrid.Gridlines object property. It should be something like that:

iGrid1.GridLines.Horizontal = new iGPenStyle(Color.LightGray, 1, DashStyle.Solid);
Igor/10Tec
2017-12-01T13:16:26Z
Originally Posted by: juanMH 


1. The CellDynamicContents event handler is called every time the row is on the screen, even if nothing has changed, this resulted in slow performance since i had to process every row more than once, is this the expected behavior, that it redraws the row every time it is on the screen and while scrolling?



The CellDynamicContents event is raised when iGrid repaints the corresponding area with cells. The purpose of the CellDynamicContents is to provide cell data dynamically not to store them inside iGrid. That's why it may be raised several times for the same cells in the view port.

Originally Posted by: juanMH 


2. Is it possible to programmatically reload a single row so that i can update images on columns or change the font style or color?



If I understand you right, you need to "ask" iGrid to invalidate the rectangle that belongs to the specified row. You can do this with the iGrid.Invalidate(Rectangle) method. To calculate the rectangle, use the iGRow.Y and iGRow.Height properties. Look also at iGRow.HdrBounds.

Originally Posted by: juanMH 


3. Finally, i noticed that when i load another set of rows into the screen, i would get the CellDynamicContents event handler called for the new last row even if it was not on the screen at the time.



This may happen if you sort iGrid or do something else when iGrid needs to know the cell values from all rows.
juanMH
2017-12-01T17:06:07Z
I have solved this now, thanks for the help

Setting the values again on the cell causes it to call the dynamic formatting handler, this solves my issue

Regards
Users browsing this topic