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.

Problem with adding manually a new row to the grid

Thread ID:

Created:

Updated:

Platform:

Replies:

24106 Jan 28,2005 03:08 AM Jan 28,2005 04:46 AM Windows Forms 2
loading
Tags: GridControl
Phuoc Tu
Asked On January 28, 2005 03:08 AM

Hi all, Please help me. I using GridDataBoundGrid. I code for 1 button to add new row: ROPStoreVO oROPStoreVO = (ROPStoreVO)gridROPStore.DataSource; if (oROPStoreVO == null) return; DataRow drwNewRow = oROPStoreVO.NewRow(); oROPStoreVO.Rows.Add(drwNewRow); this.gridROPStore.Focus(); this.gridROPStore.CurrentCell.MoveTo(gridROPStore.Model.RowCount, 1); bool isRet = this.gridROPStore.CurrentCell.BeginEdit(); It ran OK when I clicked on this button. But, when I clicked on header to sort data, and then click the button. It still added a new row but the new row went ahead. I want a new row go to the bottom. Anyone help me. Thank you so much. Phuoc Tu.

Administrator [Syncfusion]
Replied On January 28, 2005 03:52 AM

The GridDataBoundGrid only displays the rows in your datasource, and displays them in the exact order that they appear in the datasource. If you are using a DataTable as the datasource, then when you sort it, the datasource is really DataTable.DefaultView (so you datatable can be displayed as sorted.) So, when you add a row to your datatable, the defaultview will position it according to its Sort property. This is all done outside the grid, and is completely handled by the DataTable. If you want to keep using a DataTable as your datasource, to avoid this behavior means you have to handle all the sorting yourself and not relie on the sortting that depends upon Datatable.DefaultView. This takes some non-trivail coding. While it is not exactly what you need, here is a sample that shows one way to manage this problem. The idea is to handle grid.Model.QueryCellInfo and use this event to control the display order of the rows through an indexer class. This technique can be adapted to not move new rows added at the bottom until the next sort.

Administrator [Syncfusion]
Replied On January 28, 2005 04:46 AM

Here is a smple that is colser to what you want. http://www.syncfusion.com/forums/Uploads/GridDataBoundGridCustomSorting_Forum.zip

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.

;