We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

GridDataBoundGrid

Some questions. 1. Using a databound grid, if I have a pointer to a row element in my DataTable DataSource, how do I find out which cell x,y it it is being displayed in? ie a value changes in my DataTable and I want to color the cell that changed in the grid. 2. Using a GridDataBoundGrid I have to use the PrepareViewStyle event to set a cells color, is there a way I can force this to be fired for only one cell? ie invalidating everything just because the color of one cell has changed is inefficient. I dont see any InvalidateCell(x,y) methods that I can call.. 3. My DataTable datasource changes very often, I''m doing: gridControl1.BeginUpdate(); gridControl1.Binder.SuspendBinding(); //..update the datatable with stuff.. gridControl1.Binder.ResumeBinding(); gridControl1.EndUpdate(); Is there anything else I need to be doing? Thanks for your help Matthew

7 Replies

AD Administrator Syncfusion Team June 14, 2004 10:38 AM UTC

1) If you have the position of the row in the DataTable , then you can use the grid.Binder.PositionToRowIndex method to return the row index in the grid. If you are not getting the index in the chnage event you are listening to, then you might consider using the CurrencyManager.LsitChanged event. That should provide you with teh e.Index that you can pass into Biner.PsoitionToRowIndex. 2) Use grid.RefreshRange. 3) As long as your columns are not being removed/added, then you code should be sufficient. If you are modifying the columns, then you may also need to call grid.Binder.InitializeColumns.


MH Matthew Hayhurst June 16, 2004 05:52 AM UTC

1) All i have is a pointer to the System.Data.DataRow and an integer index to a column in that row. I need the x,y co-ords on the grid thats bound to this data. Any code I could perhaps reference anywhere? 2) Is it safe for another thread to be manipulating values in the Sytem.Data.DataTable that my grid is bound to? I''ve tried it as a test, but something isnt happy. Should i unbind the datatable everytime the thread makes changes to it? Thanks for the help Matthew :>


AD Administrator Syncfusion Team June 16, 2004 07:00 AM UTC

1) You will have to ''somehow'' find the DataRow object in the CurrencyManager.List to retrieve its position in this list. Once you have this position index, you can use grid.Binder.PositionToRowIndex to retrieve the row index in the grid. With the grid row and column index, you can use grid.ViewLayout.RowColToPoint to get a point in the grid. So, the problem is how do you get the position in the CurrencyManger. If you listen the CurrencyManager.ItemChanged event, that event gives it to you. If you do not want to do this, unless you have special knowledge of the underlying collection that lets you ''find'' the position of an item in the list, I think you would have to loop through CurrencyManager.List, casting each item to a DataRowView, and then compare the DataRowView.Row object to your DataRow object to see if they are equal. 2)In 2.0.5.x, there is a chance this would be OK. In 1.6.x code, this would not work. In 2.0, the grid does InvokeRequired checks around its ListChanged event handler to try to facilitate this behavior. If you are strictly working through DataTable (and not using any grid reference in your other thread), then ''in theory'', the list changes should be handled on the grid''s thread.


MH Matthew Hayhurst June 21, 2004 07:56 AM UTC

Thanks for all your help. We have benchmarked and decided the databound grid is not giving us the performance, so have decided to try the virtual grid. How hard will it be to implement column rearranging , filter bars and column grouping using a virtual grid?


AD Administrator Syncfusion Team June 21, 2004 09:18 AM UTC

Column rearranging is straight-forward. Here is one way you can do it, but there are others as well. modified VirtGrid tutorial Doing some kind of FilterBar will take more effort depending upon what you want. If you have our source code, you could use copy our implementation and try to work from there. I think this is doable. It would probably be easier to still use DataViews as the datasource for your virtual grid, and this would allow you to implement the filtering using DataView.RowFilter in a straight forward manner. You would have to insert an extra row at the top of your virtual grid, but that is more or less what our GridFilterBar code does. But I think all this is doable in a straight-forward manner. If you want collasible groups, I think this will be by far the most difficult of the requirements. If you use a DataTable as your datasource for the virtual grid, it would be straight-forward to implement multicolumn sorting (here is a KB link - http://www.syncfusion.com/Support/article.aspx?id=10489). Mulitcolumn sorting is the first step if grouping. If you can do thi, you can arrange the rows in the proper groups. But this does not give you a collapsible-group UI, and this would be where the bulk of the work would come in.


EW Ewan Wilcox June 25, 2004 10:30 AM UTC

>Column rearranging is straight-forward. Here is one way you can do it, but there are others as well. modified VirtGrid tutorial > >Doing some kind of FilterBar will take more effort depending upon what you want. If you have our source code, you could use copy our implementation and try to work from there. I think this is doable. It would probably be easier to still use DataViews as the datasource for your virtual grid, and this would allow you to implement the filtering using DataView.RowFilter in a straight forward manner. You would have to insert an extra row at the top of your virtual grid, but that is more or less what our GridFilterBar code does. But I think all this is doable in a straight-forward manner. > >If you want collasible groups, I think this will be by far the most difficult of the requirements. If you use a DataTable as your datasource for the virtual grid, it would be straight-forward to implement multicolumn sorting (here is a KB link - http://www.syncfusion.com/Support/article.aspx?id=10489). Mulitcolumn sorting is the first step if grouping. If you can do thi, you can arrange the rows in the proper groups. But this does not give you a collapsible-group UI, and this would be where the bulk of the work would come in. Hi I am working with Matthew at the minute and I was curious as to what you meant by: "Muli-column sorting is the first step if grouping."? Even if we can sort on multiple columns I don''t entirely see how that helps us group columns together. Something like: ---------------------------------- | Group 1 | Group 2 | ---------------------------------- |Item1 | Item 2 | Item 3 | Item 4| ---------------------------------- | | | | | | | | | | etc... And then be able to manipulate groups 1 and 2. For example rearrange the order of these two "groups" to get: ---------------------------------- | Group 2 | Group 1 | ---------------------------------- |Item3 | Item 4 | Item 1 | Item 2| ---------------------------------- | | | | | | | | | | etc... Thanks Ewan.


AD Administrator Syncfusion Team June 25, 2004 10:47 AM UTC

By grouping, I was speaking about outlook style grouping where you drag a header, and the rows (not the columns) are organized so all like-values for that column are grouped together. It is this behavior where multicolumn sorting is required because sorting is how you get all the like-values arranged together. I think you may be using grouping in a different way. You want headers grouped (and managed) together. Multicolumn sorting would play no role in this. You would probably use covered cells to get this look. As far as dragging a covered cell to re-arrange a group of columns, this would require you coding things to implement this functionality. Here is a link to a forum trhead that has a sample showing one technique for managing dragging columns yourself. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=9676

Loader.
Live Chat Icon For mobile
Up arrow icon