Welcome to MSDN Blogs Sign in | Join | Help

Custom Bound Fields in FieldGroup

You could make the AxBoundFieldGroup use the CustomBoundField (http://blogs.msdn.com/solutions/archive/2009/04/20/ax-custom-bound-fields.aspx) instead of the regular bound field by hooking into the OnCreatingBoundField event (KB971547) of the  AxBoundFieldFactory.

 For example create an assembly with the below code and put it in GAC.

public class AxSampleBoundFieldFactory
{
 public
void OnCreatingBoundField(object sender, CreatingBoundFieldEventArgs eventArgs)
 {
   if (eventArgs.Field.Name == "Date")
     eventArgs.BoundField =
new AxSampleDateBoundField();
 }
}

Then modify the master page (C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\DynamicsAxEnterprisePortal\defaultax.master) and add the below code to invoke this eventhandler in page init. Now any page that displays a fieldgroup will use the AxSampleDateBoundField for any field with the name "Date". You can add any logic that you want here for example you may want to use other field meta data properties instead of the name.


  private AxSampleBoundFieldFactory customBoundFieldFactory;
   
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

        // Subscribe to the bound field factory event
        this.customBoundFieldFactory = new AxSampleBoundFieldFactory();
        AxBoundFieldFactory.Instance.CreatingBoundField += this.customBoundFieldFactory.OnCreatingBoundField;
    }

    protected override void OnUnload(EventArgs e)
    {
        // Unsubscribe to the bound field factory event
        AxBoundFieldFactory.Instance.CreatingBoundField -= this.customBoundFieldFactory.OnCreatingBoundField;       
       
        base.OnUnload(e);
    }

Published Thursday, May 28, 2009 2:35 AM by meysun
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Custom Bound Fields in FieldGroup | Microsoft Share Point

Wednesday, May 27, 2009 10:03 PM by Custom Bound Fields in FieldGroup | Microsoft Share Point

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker