This is a migrated thread and some comments may be shown as answers.

error sorting grid - System.IndexOutOfRangeException: Cannot find column

1 Answer 153 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Justin
Top achievements
Rank 1
Justin asked on 10 Nov 2008, 04:08 PM
The grid initially renders fine.  When I sort on particular properties on my business object I get the "Cannot find column" error.  These particular properties are readonly properties that reference related business objects in my domain.  For example, I have a list of distributions that I'm binding to the grid, but I also want to show associated contacts.  To be able to do this I need to "flatten"  my domain objects to include readonly properties for ContactFullName or DefaultBrokerOnAccount.  By denormalizing my domain I'm able to bind related objects.  I think we all do it this way unless I'm missing something revolutionary here.  The properties in my Distribution object look like this:

        public string ContactFullName
        {
            get { return (UpToContactByContactID == null) ? "" : UpToContactByContactID.FullName; }
        }

        public string DefaultBrokerOnAccount
        {
            get { return (UpToContactByContactID == null) ? "" : UpToContactByContactID.Account.DefaultRep; }
        }

Where the property "UpToContactByContactID" is of type Contact which is associated to my Distribution object.  The telerik grid binds fine initially, but falls apart when I need to sort on these columns.  If I give these columns setters and populate them like normal properties of the Distribution object I have no problems.  This is seems to be a major issue but solvable since at least the grid recognizes the properties on the initial bind.

please help




1 Answer, 1 is accepted

Sort by
0
Justin
Top achievements
Rank 1
answered on 10 Nov 2008, 04:41 PM
Issue is resolved.  I'm using EntitySpaces as my O/R mapper.  For custom properties you need to register this properties in your custom business object like so:

        protected override List<esPropertyDescriptor> GetLocalBindingProperties()
        {
            List<esPropertyDescriptor> props = new List<esPropertyDescriptor>();
            props.Add(new esPropertyDescriptor(this, "CreateUserFullName", typeof(string)));
            props.Add(new esPropertyDescriptor(this, "DefaultBrokerOnAccount", typeof(string)));
            props.Add(new esPropertyDescriptor(this, "ApprovedUser", typeof(string)));
            props.Add(new esPropertyDescriptor(this, "ContactFullName", typeof(string)));
            props.Add(new esPropertyDescriptor(this, "BecameClientDate", typeof(DateTime?)));
            props.Add(new esPropertyDescriptor(this, "GrantedElectronicConsent", typeof(bool)));
            return props;
            //return base.GetLocalBindingProperties();
        }

Once you have done this then they are available.



Tags
Grid
Asked by
Justin
Top achievements
Rank 1
Answers by
Justin
Top achievements
Rank 1
Share this question
or