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.
Unfortunately, activation email could not send to your email. Please try again.

Grouping grid questions

Thread ID:

Created:

Updated:

Platform:

Replies:

27919 Apr 20,2005 06:16 AM Apr 21,2005 06:38 AM Windows Forms 8
loading
Tags: GridControl
Kjetil Fleischer Kåresen
Asked On April 20, 2005 06:16 AM

- 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

Administrator [Syncfusion]
Replied On April 20, 2005 07:05 AM

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?

Administrator [Syncfusion]
Replied On April 20, 2005 07:43 AM

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?

Administrator [Syncfusion]
Replied On April 20, 2005 10:56 AM

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.

Administrator [Syncfusion]
Replied On April 20, 2005 04:33 PM

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?

Administrator [Syncfusion]
Replied On April 20, 2005 05:43 PM

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

Administrator [Syncfusion]
Replied On April 20, 2005 05:52 PM

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

Administrator [Syncfusion]
Replied On April 20, 2005 06:01 PM

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?

Administrator [Syncfusion]
Replied On April 21, 2005 06:38 AM

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.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;