User (Old forums)MemberFebruary 5, 2004 at 11:13 amPost count: 23064
I’m guessing that what I need to do is not going to be possible, but I figure I will ask the question anyway, to see if anyone has any ideas.
What I’m trying to do is to allow the user of my form to right-click on a row, and use a pop-up menu to insert a blank row before the row they clicked on.
Unfortunately, the only way I know of to add a dataRow to the grid is to use DataRows.AddNew(), which does not allow us to set the index of the row being added. I could implement a hidden numbering system that would keep the rows sorted by number, but I have been encouraged by higher powers to stay away from that kind of solution.
Is there a way to change the index of a datarow without sorting the grid?
Imported from legacy forums. Posted by Christopher (had 7355 views)User (Old forums)MemberJune 2, 2004 at 6:29 amPost count: 23064
Has anyone found a solution to this yet?
I have a similar problem, in that I want the user to be able to press an ‘Insert’ button to have a new row inserted above the currently selected (data)row.
The grid is bound to a datatable and I want the datatable to be updated too.
Imported from legacy forums. Posted by rjback (had 573 views)User (Old forums)MemberJune 3, 2004 at 4:24 amPost count: 23064
I was being a bit dumb there.
Although it’d be nice for the grid to do something like this, I can always pass the info from the grid to somewhere that can manipulate my datatable. Once I’ve manually shifted the rows around the grid’ll refresh.
If I’ve changed the primary key of the rows by shifting them around I then have to make sure my dataadapter deletes before it updates before it inserts.
Imported from legacy forums. Posted by rjback (had 503 views)User (Old forums)MemberFebruary 10, 2005 at 2:11 pmPost count: 23064
I have the same problem.
I want to insert a new row in a middle of certain rows in a grid. But the AddNew method does not allow to specify a index to the item which will be inserted.
Imported from legacy forums. Posted by mauridav79 (had 418 views)Xceed SupportMemberFebruary 11, 2005 at 8:42 amPost count: 5658
It is not possible to insert datarow’s into a grid other than by using AddNew.
As a workaround to simulate insertion, create an invisible column that contains an index and sort by that column. When AddNew is called, place the desired number in the cell corresponding to the invisible column and the datarow will appear to be inserted.
Imported from legacy forums. Posted by Jenny [Xceed] (had 293 views)User (Old forums)MemberMarch 4, 2005 at 8:22 amPost count: 23064
inserting datarows must be with next version….thats my wish
Imported from legacy forums. Posted by PETE (had 633 views)User (Old forums)MemberMarch 24, 2005 at 8:39 pmPost count: 23064
I cannot begin to stress how important this feature is. Please implement this ASAP.
I am currenty using the workaround described here. It DOES NOT WORK WELL. It does work, but it is error prone and obvious. It must be supported by the grid and by the underlying data source to be seemless.
Imported from legacy forums. Posted by glenebob (had 554 views)Xceed SupportMemberMarch 21, 2006 at 1:03 pmPost count: 5658
Hi all, data rows section in the grid can be custom sorted at will, meaning you have the full control on the order of data rows.
Unless overridden, the default order of data rows is the one in witch they are added in unbound mode, or in the order of the data returned from the database if bound, this is to allow sorting and grouping functionality.
In the case you are in unbound mode or if you are managing your data yourself, you could use value rows (in fixed sections) instead of data rows and have full insert and other flexibility capabilities.
Imported from legacy forums. Posted by Vince [Xceed] (had 461 views)Xceed SupportMemberMarch 22, 2006 at 10:14 amPost count: 5658
I didn’t try it but from another uasking post:
“The other thing you could do is implement custom databinding on a non-dataset object. That way you can make changes at an instant by overrideing the indexer of the IList or IBinding list property of whatever object you have. “
Imported from legacy forums. Posted by Vince [Xceed] (had 547 views)User (Old forums)MemberMarch 23, 2006 at 4:58 amPost count: 23064
You can manipulate a bound list as the grid will call the count and index properties of the IList for instance. When you want to insert a new row increment the count and whereever you want to insert the new row, when the grid says can I have the data for row x then the index property can return the new rows data. All the other rows will be at x+1.
I think the problem that maybe alot of people have (I know I do) is the idea of seperating View from Model when using the grid. The grid is the view on a list of data which is the model and to seperate them makes life a whole lot easier and more powerful.
Inserting into the middle of a collection of datarows somewhere doesn’t matter, it’s only important to insert it into the middle of your model list and the grid will view the state of the model (adding/inserting rows where necessary). The view can then sort it’s data, hide it’s data change it’s data without affecting the model and that’s the key.
I believe that a databound grid (with custom binding) although takes a while to setup is far more powerful than an unbound grid because of the seperation you get.
It’s just a thought.
Imported from legacy forums. Posted by Chris (had 343 views)
- You must be logged in to reply to this topic.