This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I have quite sucessfully incorporated LS with our Infragistics Grids, thanks to the previous post regarding BindList<T> etc. I do however have one little problem. We have a form to create a new Purchase Order. The form contains text boxes and a single grid. A new LS Entity <PoHeader> is assigned to the DataSource of a BindingSource control, which provides the values for the text boxes. Further we create a BindingList<PoItems> for the child records, i.e. the Purchase Order items, which is set as the DataSource of the grid. These items can then be added and edited. However, I am unable to delete any rows from the grid unless I open a UOW. The problem is, when creating a new Purchase Order, we create a new instance of an Entity, and populate it, and only save it to the database when the form is comlpete, as this is when we assign a unique purchase order number. We don't create the actual database record till last, as we have many cases of POs being cancelled half way through typing in the form. What I don't really understand, is, if we are using a memory bound BindingList<PoItems>, why do we need to connect to the database to delete a row, which isn't even in the database to begin with. The error message the grid is throwing is: Unable to delete the row. Cannot access disposed object, Object name DataDALUnitOfWork. Do I really need to create a UOW even though I don't need to access the database?
|
|
|
The more I look into this problem, the more confused I become. I added the code code below on the event handler for the BeforeDeleteRows in the grid.
e.DisplayPromptMsg = false; This on first glance appeared to work, however, I noticed that the Grid was throwing a row index error when I performed this, so it actually did not complete the deletion from the database. After much trial and error, I found that this error was dependent on the grid datasource. If I used the following code, I received the error. BindingList<PoDetail> _details = _po.PoDetails; Where _po is the Purchase Order entity, and PoDetails is the EntityCollection<PoDetails> for a joined table. I thought this would be accepable as EntityCollection<T> is derived from BindingList<T>. However if I used the following code to set the grid DataSource, I do not get any errors, but I have to save the changes seperately to the _po entity. var blist = new BindingList<PoDetail>(); Maybe I am missing some key peice of information here, but these grids are driving me mad. I have many forms I am trying to convert to using LS entities, unfortunatly 80% of them include at least one grid, several use up to 5 or 6 grids all in Parent/Chidl relationships. Please help me to understand this, so I can get a reliable template of grid interactions to use on all the forms. Thanks |
|
|
Hi Mark, Thanks for your post, hopefully we can work through a better solution for you. First off, some background. The reason why Remove() requires a unit of work is because LightSpeed does things like walk associations and removes associated items if cascade deletes is enabled and because there are life-cycle events available for you to use which you would expect to have an active unit of work available for you to use. Admittedly, in your situation, it sounds like you don't care about those scenarios but I just wanted to explain the thinking behind needing a UoW even if your entity is not yet in the database. It sounds like the ideal pattern would be just using the child collection however I'm not sure why the grid will not accept the EntityCollection happily given it does implement IBindingList but perhaps you should bring that up with Infragistics? Was it swallowing the initial row index error? If you post on the infragistics forum about this issue could you post a link here as I would be more than happy to provide any information to them about the design of LightSpeed to ensure the problem gets resolved quickly. Just to clarify, the final code sample is working for you correct? But you're hoping to get a more elegant solution that doesn't lose the nice hierarchical object style of just using the child collection? Hopefully we can work out this strange behavior with the grid quickly. John-Daniel |
|
|
Hi John-Daniel, Thanks for the explanation regarding the Remove option and its requirements for the UoW, now I understand. With regard to the BindingList and the Infragistics Grid, until now I have not contacted Infragistics, as I am not confident that is where the problem lies. As I mentioned in my previous post, if I manually create a BindingList the grid seems to work correctly, it is only when I use the child collection that it does not work. This leads me to the conclusion the problem is more likely to be in the child collection rather than the grid. But of course I am willing to accept I may be wrong. I will in the meantime, look to see if anyone else has reported problems with Infragistics tools and BindingList. Thanks Mark
|
|
|
Hi Mark, Thanks for the feedback :-) I'm working a little in the dark on this one because I don't have an infragistics grid available to test against so I'm just trying to shake out any possible issues. In your code example, it looked like if you assigned an entitycollection, it failed, if you assigned a BindingList directly, it succeeded. Perhaps I've misunderstood the issue but it sounds almost like the grid doesn't like it when BindingList has been inherited from rather than seeing that type exactly. That's the only reason behind thinking it could be something odd with their grid. It's certainly not me trying to just dodge an issue - just thinking about it from all sides :-) I'm not sure how the infragistics licensing system works, but perhaps if it is possible, you could provide me a repro that I could run here just to test it out? Kind regards, John-Daniel |
|
|
Hi John-Daniel, Firstly I am sorry if I gave the impression you were try to"dodge" the issue, I promise you that was not my intent. With regards to the Infragistics grids, you can download a free 30 day demo from the Infragistics website. That is a 100% working version, it just expires after 30 days. Sending you a source code project would not work unless you already had the Infragistics tools on your computer. Then it would also need to be the same version. If you can download a 30 day version, I will obtain the same version, I will then try to make a simple example to demonstrate the problem. Best regards Mark |
|
|
Hi Mark, Excellent, I'll download the 30 day trial. Is this with Winforms or WPF? You can email the repro to support@mindscape.co.nz Thanks! John-Daniel |
|
|
Hi John-Daniel, I am using the Winforms version. Will send the trial project asap. Regards Mark |
|
|
Thanks Mark. I have pulled down the Winforms components to test against. Could you let me know once you have emailed your repro? Our mail server (google) can be a bit paranoid about attachments containing binaries so I wouldn't want to have it blocked and you think I have the repro! I've got to head out of the office for the rest of today (it's 4:15pm here in New Zealand) but I will look into this first thing tomorrow morning for you. I hope that helps, John-Daniel |
|
|
That's funny, most of my NZ friends here go home about 4pm as well. ;-) No problem, will get the repro done asap and hopefully you will get it by tomorrow morning. Thanks for all your help.
|
|
|
Hi Mark, Did you manage to put together the repro? I haven't received anything so if you have sent it could you please try again with all binary files removed? Cheers, John-Daniel |
|
|
Just finishing the repro now. Will send very soon. Will let you know when sent. Thanks
|
|
|
Have just emailed the repro app. Let me know if you have any problems. Thanks |
|