I use the virtual mode with my UltraGrid. When a new data record is added to my own data source and I increase UltraDataSource row count by one. Event InitializeRow of UltraGrid is always fired on the last grid row. For example, if a newly added data record is displayed on the top, the InitializeRow event is always fired on the first added data record, since it is tired to the bottom grid row.
If I need to setup row level appearances, I have go through all the grid rows. Is there a way to get around with this issue?
Thanks,
Shaolin
Hi Shaolin,
I need to get a better understanding of what and how you are doing it. How are you adding the data to the top of your UltraDataSource are you calling Rows.Insert()? If you just adding the row to your backend datasource, and then just calling SetCount(), being that it is virtual, and therefore not directly bound to the UltraGrid, the UltraGrid probably just hasn't gotten notification that your backend changed. You need to refresh it in some way, like grid.Rows.Refresh()
Let me know if that helps,
Hi Michael,
Thanks for your response!
I have my own data source and the data records in it are sorted. I only use an UltraGrid for display purpose. The UltraGrid does display data correctly in my case. The issue is event InitializeRow is always fired on the bottom row.
I do understand that you are using the UltraGrid for display, but again, you are adding a row, how are you adding it? If you are adding it to your Root DataSource, and just increasing the UltraDataSource's row count, the UltraGrid only sees that a new row was added to the end because from what you are describing the only notification you gave the grid was via the middle tier DataSource setting it's RowCount to up one, so that would be correct. If you think that is not what is happening, would you be able to mock up a sample that demonstrates the behavior that you are describing?
I use method SetCount().
I apologize, testing it again, if you are not using the Insert method, you should be using grid.Rows.Refresh(RefreshRow.FireInitializeRow), if you want the InitializeRow to fire, but it will file for all rows. If you use just the Insert method it will only fire for the row you are inserting.
Michael GermannSoftware Development Team LeadInfragistics
Hi Mike,
The following two lines did not cause InitializeRow event to fire:
UltraDataSourceObject.ResetCachedValues()UltraGridObject.Rows.Refresh(RefreshRow.RefreshDisplay)
How do I know if an UltraGridRow is initialized? Does UltraGridObject.Rows have all UltraGridRow objects including initialized? Can I set Appearance to an uninitialized UltraGridRow?
If you are adding the rows to the top, then unfortunately you will need to have refire the InitializeRow event for every row that moved at the least, likely for each row that is re-painted. Mostly because the indexes for all of them will change. Since you are bound to an UltraDataSource, if you know where positionally the new row will be in your DataSource, if you call UltraDataSourceObject.Rows.Insert(index, false) that should be all you would need.
If you don't have that information, or would rather not go that route, you can use the UltraDataSourceObject.Rows.SetCount(newCount) but you will also need the following:UltraDataSourceObject.ResetCachedValues()UltraGridObject.Rows.Refresh(RefreshRow.RefreshDisplay)
I believe the first approach will be more performant though. Let me know which way works best for you,
I need to setup appearance for each row. So whenever data are changed, I have to set appearance for each row. It is not a right way to set appearance for each row using Event InitializeRow. Can you suggest a way to do it please? I am using virtual mode and have thousands of rows, so performance is very important.
Sionce you are just setting the count up, the UltraGrid only sees that a new row was added to the end because from what you are describing the only notification you gave the grid was via the middle tier DataSource setting it's RowCount to up one, via the SetCount method, so the behavior you are getting is expected. If you think that is not what is happening, would you be able to mock up a sample that demonstrates the behavior that you are describing?