BBS ... DevExpress and Custom Fields


Author
Message
Charles Thomas Blankenship...
Charles Thomas Blankenship
StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)
Group: Awaiting Activation
Posts: 172, Visits: 12K
Hey ... who told you and didn't tell me ... once again I worship at the alter of the StrataFrame Gods.

You know what pisses me off ... I mean really pisses me off ... why does a sh*t product like DNN eclipse our user base in terms of seats ... I just don't freakin' get it.

Charles T. Blankenship
Senior Consultant
Novant Consulting, Inc.
704.975.7152
http://www.novantconsulting.com
StrataFrame Team
S
StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Yep, Ivan nailed it.  There's 

bo.CurrentDataTable.AcceptChanges();

and

bo.CurrentRow.AcceptChanges();

Whichever one you need.  They both accept the edited values of the ADO.NET object as original values.

FYI, this is the same thing we call on each row after it gets updated back to the database.
Ivan George Borges
Ivan George Borges
Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)Strategic Support Team Member (3.6K reputation)
Group: StrataFrame MVPs
Posts: 1.9K, Visits: 21K
YourBO.CurrentDatatable.AcceptChanges()
Charles Thomas Blankenship...
Charles Thomas Blankenship
StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)
Group: Awaiting Activation
Posts: 172, Visits: 12K
Well, I knock down on weed and another one grows in its place ... the reason I wanted to perform an ID lookup after the initial join was to prevent the slowdown of the query just for looking up the name of the Telemarketer.  So, I created a custom property, gave it a descriptor and bound that column to the XtraGrid.  The data shows up without incident.

However ...

since I'm placing a value into one of the fields of the business object the business object is now "dirty" and it screws up the maintenance form toolbar button states. 

Furthermore, each time the Undo button is pressed all of the Telemarketer names are erased from the column as they are in effect, changes to be rejected from the table.

How does one go about resetting the editing status of that particular field ... or ... keep it from registering a dirty business object altogether.

Thanks,

Charles T. Blankenship
Senior Consultant
Novant Consulting, Inc.
704.975.7152
http://www.novantconsulting.com
Charles Thomas Blankenship...
Charles Thomas Blankenship
StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)
Group: Awaiting Activation
Posts: 172, Visits: 12K
Yep ... that worked ... it is a good thing this is not 1692 in Winston, Salem ... if it were I'd have all of you burned as witches ... as this worked like magic.

Charles T. Blankenship
Senior Consultant
Novant Consulting, Inc.
704.975.7152
http://www.novantconsulting.com
Charles Thomas Blankenship...
Charles Thomas Blankenship
StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)
Group: Awaiting Activation
Posts: 172, Visits: 12K
This mebbe?

protected override FieldPropertyDescriptor[] GetCustomBindablePropertyDescriptors()
{
    FieldPropertyDescriptor[] fpd = {new ReflectionPropertyDescriptor("lea_RecallOn", typeof(Lead))};
    return fpd;
}


Charles T. Blankenship
Senior Consultant
Novant Consulting, Inc.
704.975.7152
http://www.novantconsulting.com
Edited 11 Years Ago by Charles Thomas Blankenship
Charles Thomas Blankenship...
Charles Thomas Blankenship
StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)
Group: Awaiting Activation
Posts: 172, Visits: 12K
Well ... I hate to be dense in public but would one of you please speak C#?  Here is my custom property ...

        [Browsable(false),
         BusinessFieldDisplayInEditor(),
         Description("DialRecalls.dir_RecallOn"),
         DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public DateTime lea_RecallOn
        {
            get
            {
                return (DateTime)this.CurrentRow["lea_RecallOn"];
            }


            set
            {
                this.CurrentRow["lea_RecallOn"] = value;
            }


        }       



Charles T. Blankenship
Senior Consultant
Novant Consulting, Inc.
704.975.7152
http://www.novantconsulting.com
Edhy Rijo
E
StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)StrataFrame VIP (4.7K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Charles,

I was working outside yesterday and did not see your post until now.  I also use DevExpress grids a lot and with several Custom Field Properties (which is one of the most useful features of the SF BO).

Follow Ben's recommendation overriding the GetCustomBindablePropertyDescriptors() and you should be good to go.


Edhy Rijo

StrataFrame Team
S
StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)StrataFrame Developer (4.7K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Howdy CT,

The post that Ivan gave is the way it's designed to work.  We implement the ICustomTypeDescriptor interface on BusinessLayer in order to filter out the properties that most people don't need to look at on the business object.  Properties like CurrentRow, CurrentDataTable, IsDirty, Count, etc. would show up in the grid if we didn't filter down to only the properties that are mapped.  If you add a custom property to your business object, you need to add your property to the list of properties that are exposed for binding, otherwise, it gets filtered out with all of the other properties that are not "mapped" properties.

The way to do this is to override the GetCustomBindablePropertyDescriptors and return a property descriptor for your custom property.  The ReflectionPropertyDescriptor was created to be the easiest way to do it.  Like this:

    Protected Overrides Function GetCustomBindablePropertyDescriptors() As MicroFour.StrataFrame.Business.FieldPropertyDescriptor()
        '-- Create and return a new array of FieldPropertyDescriptor
        ' objects that contains the ReflectionPropertyDescriptor
        ' for the custom field.
        Return New MicroFour.StrataFrame.Business.FieldPropertyDescriptor() { _
            New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor("myFieldProperty", GetType(MyBO))}
    End Function

I hope this helps the next time you need to bind a custom property to a grid (or TextBox or anything else).
Charles Thomas Blankenship...
Charles Thomas Blankenship
StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)StrataFrame User (464 reputation)
Group: Awaiting Activation
Posts: 172, Visits: 12K
After pounding my head on the desk for a while ... I went down and watched Hardball with Chris Matthews ... and came up with this.

There does not seem to be a performance hit with this solution and it does exactly what I want it to ... I just thought the BBS would be a bit more straight forward. 

The problem it seems is that DevExpress XtraGrid does not care about custom properties ... they don't show up in the designer when populating the grid either ... which is a clue.

This solution takes the lea_id out of the grid, which comes directly from the table and uses that to seek to the primary key of the business object and then pluck the value out of the custom property and push it into the unbound column.


        private void grvLeads_CustomColumnDisplayText(object sender,  DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
        {
            ColumnView view = sender as ColumnView;


            if (e.Column.FieldName == "lea_Phone")
            {
                string phone = (string)view.GetRowCellValue(e.RowHandle, view.Columns["lea_Phone"]);
                e.DisplayText = string.Format("{0Sad###) ###-####}", Convert.ToDouble(phone));
            }


            if (e.Column.FieldName == "lea_RecallOn")
            {
                int leadID = (int)view.GetRowCellValue(e.RowHandle, view.Columns["lea_id"]);
                oLead.SeekToPrimaryKey(leadID);
                e.DisplayText = string.Format("{0:d}",oLead.lea_RecallOn);
            }
        }


Charles T. Blankenship
Senior Consultant
Novant Consulting, Inc.
704.975.7152
http://www.novantconsulting.com
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search