Rendering Custom Fields in a SnapSection

Discussions related to SoftPro Select user interface development.

Moderator: Phil Barton

Post Reply
jcreyes
Posts: 8
Joined: Tue Nov 18, 2008 10:44 pm

Rendering Custom Fields in a SnapSection

Post by jcreyes »

Are there any available methods in the SoftPro API that we can use to render or embed CustomField controls (i.e. Currency, Date, FlowText, etc) in a SnapSection given that we're able to retrieve the CustomField definition?
Mark McKenna

Re: Rendering Custom Fields in a SnapSection

Post by Mark McKenna »

The preferred way to add custom field data to your screen is by adding either (a) a CustomFieldSnapSectionContainer, or (b) a CustomFieldSnapSection element directly to your screen definition XML.

(a) The CustomFieldSnapSectionContainer simply injects a placeholder that tells our system to dynamically find all the active, non-hidden custom fields that are defined for a particular business object context (like "Loan" or "Buyer"), and display them all. Many of our default screens already have this in place, which is where the Custom Fields section comes from at the bottom of some screens. Unless you're building your own screens to replace ours, this is generally not needed.

(b) The CustomFieldSnapSection allows you to add a single custom field to the screen in its own small snapsection (it consumes minimal vertical space). As it turns out, this is the very "building block" that makes up the overall content that would be displayed inside the CustomFieldSnapSectionContainer above. For example, you could add a new custom field named "MyField#" to the Loan object, and then add a snapsection for that new field in the middle of the screen (just be sure that you put a "Loan" custom field onto a "Loan-based" screen). Like this:

Code: Select all

...
<SnapSection>
    <Name>SnapSectionA</Name>
</SnapSection>
<SnapSection>
    <!-- Format is Object.Field^LabelOffsetX^LabelOffsetY -->
    <Settings>Loan.MyField#^11^0</Settings>
    <Name>CustomFieldSnapSection</Name>
</SnapSection>
<SnapSection>
    <Name>SnapSectionB</Name>
</SnapSection>
...
jcreyes
Posts: 8
Joined: Tue Nov 18, 2008 10:44 pm

Re: Rendering Custom Fields in a SnapSection

Post by jcreyes »

Thanks Mark for the prompt response. Is it possible to change the layout of the CustomFields such that they render horizontally (left to right) instead of vertically (top to bottom) by passing a value in the Settings node of the CustomFieldSnapSection?
Mark McKenna

Re: Rendering Custom Fields in a SnapSection

Post by Mark McKenna »

Not currently. Each snapsection consumes the width of the screen, and so the building blocks are simply stacked on top of one another.
jcreyes
Posts: 8
Joined: Tue Nov 18, 2008 10:44 pm

Re: Rendering Custom Fields in a SnapSection

Post by jcreyes »

I guess I have no choice but to create my own snap section for grouping multiple custom fields together in either a horizontal or vertical layout. Is there a way for me to access and render the custom user controls that SoftPro uses for rendering Custom Field types such as Flow Text, Date, DateTime, etc? Or do I have to create this custom user controls myself to be able to dynamically embed them in my own snap section?

My code for rendering the custom fields currently looks like this:

Code: Select all

Private Sub RenderCustomField(ByVal customFieldType As String, _
                            ByVal customFieldCode As String, _
                            ByVal customFieldLabel As String)

        Select Case customFieldType
            Case "Checkbox"
                RenderCheckBox(customFieldCode, customFieldLabel)
            Case "Currency"
            Case "Date"
            Case "DateTime"
            Case "Drop-down"
            Case "Flow Text"
            Case "Number"
            Case "Percent"
            Case "Phone"
            Case "SSN"
            Case "Text"
            Case "Time"
            Case "TIN"
            Case "Zip"
        End Select
    End Sub

 Private Sub RenderCheckBox(ByVal name As String, _
                         ByVal text As String)

        Dim chkBox As New System.Windows.Forms.CheckBox
        chkBox.Name = name
        chkBox.Text = text
        chkBox.AutoSize = True

        flpCustomField.Controls.Add(chkBox)

    End Sub
Mark McKenna

Re: Rendering Custom Fields in a SnapSection

Post by Mark McKenna »

Sorry for the delayed reply. If you are OK with stacking the custom fields vertically, which you could do inside its own container if you wish, then you don't need to do anything special. The CustomFieldSnapSection takes care of that for you at runtime. When you provide the "Settings" element to the Screen Definition XML you are providing us with enough information for us to dynamically build the control for you. For example, if you create a text-based custom field on the Loan context called "MyField#" with maximum length 10, we will create a TextBox control with MaxLength 10 for you. Just do this in the screen definition XML:

Code: Select all

<SnapSection>
    <!-- Format is Object.Field^LabelOffsetX^LabelOffsetY -->
    <Settings>Loan.MyField#^11^0</Settings>
    <Name>CustomFieldSnapSection</Name>
</SnapSection>
And Select will take care of the rest.

We don't currently support adding custom fields to a snapsection outside of those I've mentioned if you are wanting to arrange them differently. The definitions themselves are not publicly accessible so you would lose all the dynamic support that we provide (e.g. length constraints, control types, dropdown list entries, etc.).
jcreyes
Posts: 8
Joined: Tue Nov 18, 2008 10:44 pm

Re: Rendering Custom Fields in a SnapSection

Post by jcreyes »

Thanks again Mark. One last question - I went looking around for the user controls used for rendering the CustomFields in the SoftPro assemblies, and I found out that the SoftPro.UI.Controls assembly contains the following friend classes: SoftProDatePicker, SoftProPercentBox and SoftProFlowTextBox among others that correspond to the CustomField controls Date, Percent, and Flow Text respectively. Is there any way we can access and use this controls for our own SnapSections?
Mark McKenna

Re: Rendering Custom Fields in a SnapSection

Post by Mark McKenna »

Those controls are all internal, as you've discovered. We don't currently support adding controls to your own snapsections that represent bound Select data. We do, however, currently allow for screens to be customized using our snapsections as building blocks. The ability to customize your own snapsections with bound data has been requested and is being considered for a future release.
Post Reply