Home Forums WinForms controls Xceed Grid for WinForms Inserting into the middle of a group of DataRows

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #12918 |

    Hi,

    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?

    Thanks,
    Christopher

    Imported from legacy forums. Posted by Christopher (had 7355 views)

    User (Old forums)
    Member
    Post 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)
    Member
    Post 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)
    Member
    Post count: 23064

    Hi all,

    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.

    Any pointers?

    regards,
    Mauricio.-

    Imported from legacy forums. Posted by mauridav79 (had 418 views)

    Xceed Support
    Member
    Post count: 5658

    Hey Guys,

    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)
    Member
    Post 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)
    Member
    Post 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.

    -Glen

    Imported from legacy forums. Posted by glenebob (had 554 views)

    Xceed Support
    Member
    Post 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 Support
    Member
    Post 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)
    Member
    Post 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)

    User (Old forums)
    Member
    Post count: 23064

    Are any of these features ever going to be implemented?

    Imported from legacy forums. Posted by Nathan (had 8006 views)

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.