XamDataGrid & CslaDataProvider

XamDataGrid & CslaDataProvider

Old forum URL: forums.lhotka.net/forums/t/5884.aspx


ajj3085 posted on Wednesday, November 26, 2008

Hi,

I was wondering if anyone else here is using XamDataGrid with Csla.  I'm having a problem where at run-time, if the CslaDataProvider returns a BLB which contains no items, the grid does not display the "New Row" to appear. 

I tried to reproduce the issue without Csla, and was unable to.  The ObjectDataProvider worked properly (although it still called GetList even though I set IsIntialLoad = false).  As soon as I switched things to be Csla objects (BindingList -> BusinessListBase, object -> BusinessBase, ObjectDataProvider -> CslaDataProvider) I got the wierd behavior.

Any ideas?

Thanks
Andy

ajj3085 replied on Wednesday, November 26, 2008

I'm narrowing in on the cause of this.  It's something about BLB, although I'm not sure what.  If I create a fake class, MyBLB<T, C> : Csla.Core.ExtendedBindingList<C> the problem doesn't occur.  But switching back to BLB causes the new row template to disappear.

Not saying Csla is the cause; just that something in the interaction of BLB and XamDataGrid is causing it... I'll post more as I find it..

ajj3085 replied on Wednesday, November 26, 2008

Ok... here's what I've discovered.

Somehow... going through the dataportal seems to be the key.

Given this class:
    [Serializable]
    public class MyListSubclass<T, C> : Csla.Core.ExtendedBindingList<C> {

    }

    [Serializable]
    public class MyList : MyListSubclass<MyList, MyObject> {
        public static MyList GetList() {
            return DataPortal.Create<MyList>();
            // return new MyList();    // If you comment the above line and uncomment this, the grid works as expected.
        }

        [RunLocal]
        private void DataPortal_Create() {

        }

        protected override object AddNewCore() {
            MyObject result;

            result = MyObject.New();
            OnAddingNew( new AddingNewEventArgs( result ) );
            Add( result );

            return result;
        }

        private MyList() {
            AllowEdit = true;
            AllowNew = true;
            AllowRemove = true;
        }
    }

At this point, I'm totally at a loss... does anyone have any ideas what might be going on?

Fintanv replied on Wednesday, November 26, 2008

We are seeing the same thing, but have not yet had time to dig into the underlying cause.

I have been spending my time attempting to get the PropertyStatus control working with the XamGrid, or some other way to display the IDataError info in the grid, but so far without much success.

ajj3085 replied on Wednesday, November 26, 2008

There's a way to sort of get IDataError working with the grid, but it suffers some drawbacks in my mind.  Here's the link to the article anyway though.  My main issue is that the code doesn't respond to PropertyChanged events, it requires that the cell lose it's focus.  But maybe that will be enough to work for you.

Fintanv replied on Tuesday, December 09, 2008

Did you ever find out anything further on this issue?

ajj3085 replied on Tuesday, December 09, 2008

I was able to reproduce this issue outside of Csla.  See my thread here at Infragistics:  http://forums.infragistics.com/forums/t/17008.aspx

I've also posted a support issue with this.  I did find the cause of this behavior at least though.  If the first query by the DataSourceProvider subclass fails, and then you subsequently call Refresh and the resulting collection is empty, the new row doesn't display. 

There's a sample application attached to my forum post there you can check out.  If you add a static method overload that doesn't take parameters, everything works fine.  If the first refresh results in an error (because the method isn't there in my sample), the grid fails.

Copyright (c) Marimer LLC