I have a grid, when the user selects a row, I want the selected row to be displayed as 2 rows. The top row is the grid row and the bottom row is a buttons row. The buttons row would have buttons like "Cancel" on clicking which user''s chnages to this row will not be commited and so on. When the user selects a row, and I display the buttons row, the remaining ( below the selected row ) rows in the grid have to move down by 1 row to accomadte the buttons row. How do I do this?
ADAdministrator Syncfusion Team September 20, 2004 09:53 AM
I would try to handle the CurrentCellMoved and CurrentCellMoving event. In CurrentCellMoving save the old row index. In CurrentCellMoving You can compare the current cell row index with old rowIndex and if it is on a new row Model.Rows.InsertRange to insert a row into a GridControl.Model.
In CurrentCellMoving you can check if the current cell is moved off the current row and if that''s the case call Model.Rows.RemoveRange to remove the bottom row.
MBMadhavi BalusuSeptember 20, 2004 02:13 PM
Do you have a sample for this? When I tried to do what you suggested, my grid behaved really weird. I am using a GridDataBoundGrid..
ADAdministrator Syncfusion Team September 20, 2004 07:10 PM
Oh, with a GridDataBoundGrid it''s a totally different story.
One idea I have would be to use a multiple row per record layout as shown in the MultiRowRecord. Only that in the second row you just leave it empty.
Next thing is you override QueryRowHeight and set e.Size = 0 / e.Handled = true for every second row so that by default these rows are not shown - the scrollbars will be a bit jumpy but the only other way would be to manually call HideRows and HideRows might not scale well when you have too many records. If it can be more that a 1000 rows or so I would prefer QueryRowHeight override.
When you select the record you then set a variable that the QueryRowHeight should return a real height (or you set HideRows[rowIndex] = false) for that record and you call refresh. A good place for this would be CurrentCellMoving and CurrentCellMoved.
If you have a limited number of records try HideRows (better scrollbars). If you have lots of records then try QueryRowHeight. To fix the jumpy scrollbar behavior you could also handle the VerticalScroll event and increase/decrease se.NewValue (I can help you with that once you got the other things working ...)