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

Grouping grid questions

- If I save the dataset data to the DB when the a cell is in edit mode, the current edit value is not saved. How do I end the edit mode from code to avoid this? - When multi-row data is pasted to the grid, the displayed value in the first cell will not be updated immediately. The displayed value is updated to the pasted value only after I exit the cell, e.g. with an arrow key. Is there a solution for this? - If the user clicks an column header (by accident) when a new row is in edit mode the grid crashes with the following exception. Will there be fix for this? An unhandled exception of type ''System.NullReferenceException'' occurred in syncfusion.grouping.base.dll

8 Replies

AD Administrator Syncfusion Team April 20, 2005 11:05 AM UTC

1) Try this code: this.gridGroupingControl1.TableControl.CurrentCell.EndEdit(); this.gridGroupingControl1.CurrencyManager.EndCurrentEdit(); 2) Try handling these two events. this.gridGroupingControl1.TableModel.ClipboardPaste += new GridCutPasteEventHandler(TableModel_ClipboardPaste); this.gridGroupingControl1.TableModel.ClipboardPasted += new GridCutPasteEventHandler(TableModel_ClipboardPasted);
private void TableModel_ClipboardPaste(object sender, GridCutPasteEventArgs e)
{
	GridModel model = sender as GridModel;
	model.ActiveGridView.CurrentCell.EndEdit();
}
private void TableModel_ClipboardPasted(object sender, GridCutPasteEventArgs e)
{
	this.gridGroupingControl1.CurrencyManager.EndCurrentEdit();
}
3) I could not reproduce this problem in a simple sample. Can you tell us how to see it in one of our samples, or can you upload a sample showing the problem?


AD Administrator Syncfusion Team April 20, 2005 11:43 AM UTC

Solutions 1) and 2) worked fine for the first level of the grid, but not for the second. Can you also give me an example of the code I must add for the second level. 3)I was able to reproduce the problem in the "DataBoundToExternalTextBox" sample. (Type in something in new row and then click column header.) 4) Additional question: Is it possible to get cell selection with shift-arrow like in excel?


AD Administrator Syncfusion Team April 20, 2005 02:56 PM UTC

1) You will need to loop through the nested tables.
foreach(GridTable gt in this.gridGroupingControl1.Engine.EnumerateTables())
{
	GridRecord r = gt.CurrentRecord as GridRecord;
	gt.TableModel.ActiveGridView.CurrentCell.EndEdit();
	if(r != null)
		r.EndEdit();
}
2)You will have to subscribe these events on all nested tables. So in Form.Load (not the contructor) after the DataSource has been set so the tables are known, use code like this to subscribe to the events:
foreach(GridTable gt in this.gridGroupingControl1.Engine.EnumerateTables())
{
	gt.TableModel.ClipboardPaste += new GridCutPasteEventHandler(TableModel_ClipboardPaste);
	gt.TableModel.ClipboardPasted += new GridCutPasteEventHandler(TableModel_ClipboardPasted);
}
Then the handlers could look like:
private void TableModel_ClipboardPaste(object sender, GridCutPasteEventArgs e)
{
	foreach(GridTable gt in this.gridGroupingControl1.Engine.EnumerateTables())
	{
		GridRecord r = gt.CurrentRecord as GridRecord;
		gt.TableModel.ActiveGridView.CurrentCell.EndEdit();
		if(r != null)
			r.EndEdit();
	}
}

private void TableModel_ClipboardPasted(object sender, GridCutPasteEventArgs e)
{
	this.gridGroupingControl1.Table.CurrentRecord = null;
}
3) I can see this problem in 3.0.1.0, but it is not in our lastest code build here. What version of our library are you running? 4) There are two selection architectures in GridGroupingControl. One is designed specifically for this control and can be used to select whole records. You indicate that you want to use this support by setting grid.TableOptions.ListBoxSelectionMode to something other than none and grid.TableOptions.AllowSelections to None. Then you will use this record selection mode. It is illustrated in the \Syncfusion\Essential Suite\3.0.1.0\Windows\Grid.Windows\Samples\Grouping\MultipleRecordSelection sample. If you set the grid.TableOptions.AllowSelections to something other than None, you will use the selection architecture inherited from GridControlBase. If you set AllowSelections to Any, then you will be able to use the keyboard to select cell ranges. But this will only work properly with in a single table. If you try to do things in a way the crosses more than one table, things do not work properly.


AD Administrator Syncfusion Team April 20, 2005 08:33 PM UTC

1) I added you code and now it works fine. 2) I added your code. Everything now looks fine after pasting. But there is one remaining problem. If I save to the DB immediately after the paste, the first cell is lost again. Even though it is shown on screen and I have implemented 1) However if I arrow to a different cell before saving the first cell is also saved. I have tried all possible ways of calling EndEdit, but this doesn''t seem to help. 3) I''m using version 3.0.1.0 (downloaded quite recently) If the problem is solved in your newer build I will download that when it becomes available (no hurry). 4) If I use ListBoxSelectionMode != None it doesn''t seem possible to copy blocks of cell. Therefore I prefer to use GridSelectionFlags.Any. I think multiple cells copy/paste is a very nice feature for users that are used to excel. (Not found in many other grids!) However, even though I use GridSelectionFlags.Any I am not able to select with shift-arrow. Is there any other option I should set as well?


AD Administrator Syncfusion Team April 20, 2005 09:43 PM UTC

4) You have to set ListBoxSelectionMode = None to be able to select cells.


AD Administrator Syncfusion Team April 20, 2005 09:52 PM UTC

4) The keyboard cell selection support is only available in GridControl and GridDataBoundGrid. It is not currently supported in GridGroupingControl.


AD Administrator Syncfusion Team April 20, 2005 10:01 PM UTC

3) I cannot see this problem in this sample. http://www.syncfusion.com/Support/user/uploads/GGC_Delete_cc21e079.zip In it, you can open a node in the top grouping grid and open the same node in the GridDataBoundGrid at the botteom. Then if you paste some values in the top groupinggrid, then immediately show up in the bottom grid. This suggests the values were properly put into the underlying datasource. Can you see the problem you are having in this sample? Or can you upload a sample project showing the problem?


AD Administrator Syncfusion Team April 21, 2005 10:38 AM UTC

It is a bit difficult for me to upload working code because this would require stripping out a lot of DB access etc. However, I made some progress in tracking the problem. After the paste, the value in the underlying ADO DataRow is changed, but the RowState property is Unchanged. To change the RowState to Updated it is necessarry to call EndEdit() on the DataRow. I was not able to figure out how to do this through the grid, but the following (not very elegant) code solved the problem foreach(DataRow dr in table.Rows) { dr.EndEdit(); } Using this code I didn''t need the second pasteeventhandler. Finally, a couple of wishes for a future release: 1) shift-arrow selection in grouping grid 2) When pasting to a sorted column the results go in unexpected rows. I guess this happens because the grid is repeatedly sorted during the paste. I think it would be better to postpone the sorting until the paste was finished.

Loader.
Up arrow icon