Setting up a grid / BO with related fields


Author
Message
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 Greg,

Thanks for such a detail response, it helps me a lot.

Edhy Rijo

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.5K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Glad that helped BigGrin
Peter Jones
Peter Jones
Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)
Group: Forum Members
Posts: 386, Visits: 2.1K
Hi Greg,

Thanks for taking the time to write Arrays 101 - your comments are indeed very helpful.

Cheers, Peter

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.5K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Yeah, that whole curly bracket thing confused the heck out of me at first too. It is related to arrays. First lets look at some simple array examples:



' An array of strings

Dim names As String()

' An array of integers

Dim ages As Integer()

'An array of FieldPropertyDescriptors

Dim descriptors As FieldPropertyDescriptor()




You probably already figured out this is how you dim an array. Of course, then you have to Redim it to the correct size and then add each item, which is a pain lots of times:



' Dim an array of names

Dim names As String()

'...later in code, size and fill the array

Redim names As String(2)

names(0) = "Joe"

names(1) = "John"




As you likely know, with other types of variables, you can just set the value or initialize the variable when you dim it. But how do you do that with an array? Arrays need to be sized before adding elements to them and the elements are added by index. That is were the curly brackets come into play. The curly brackets are array initializers and allow you set the initial values of the array:



' An array of strings

Dim names As New String() {"Joe","Bob","Sam"}

' An array of integers

Dim ages As Integer() {23, 34, 56}

'An array of

Dim descriptors As FieldPropertyDescriptor() { _

New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _

"Product", GetType(boPUNAllocatedToFleshBatch)), _

New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _

"BinCode", GetType(boPUNAllocatedToFleshBatch))}




So, the curly brackets simply allow you to initialize the array with values when you create the array. Note that you do NOT set the size of the array when you use an initializer (the curly brackets). You can also use initializers with multi dimension arrays. In that case, you need to set the rank of the array, but not the size:



' Array of names, first in 0 and last in 1

Dim names As String(,) { {"Joe", "John"}, {"Smith","Simpson"} }




Hope that helps!
Peter Jones
Peter Jones
Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)Advanced StrataFrame User (522 reputation)
Group: Forum Members
Posts: 386, Visits: 2.1K
Hi Guys,

Yes - it all worked as advertised (in the SF Help) - thanks a lot. The only issue I had (being a .Net newbie) was how to get all my (seven off) custom fields into GetCustomBindablePropertyDescriptors. This turned out to be easy but I thought I would post the code in this thread in case someone else has similare issues. It hasn't sunk in what yet as to the special meaning of the swiggly braket but my offsider pointed out what I needed to do.


   Protected Overrides Function GetCustomBindablePropertyDescriptors() As MicroFour.StrataFrame.Business.FieldPropertyDescriptor()

        Return New MicroFour.StrataFrame.Business.FieldPropertyDescriptor() { _
             New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _
            "Product", GetType(boPUNAllocatedToFleshBatch)), _
             New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _
            "BinCode", GetType(boPUNAllocatedToFleshBatch)), _
             New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _
            "ReceiveBatch", GetType(boPUNAllocatedToFleshBatch)), _
             New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _
            "FleshingBatch", GetType(boPUNAllocatedToFleshBatch)), _
             New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _
            "ShortTermBatch", GetType(boPUNAllocatedToFleshBatch)), _
             New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _
            "TanningBatch", GetType(boPUNAllocatedToFleshBatch)), _
             New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _
            "OrderNo", GetType(boPUNAllocatedToFleshBatch))}
    End Function

Cheers, Peter

thegwill
thegwill
StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)StrataFrame Beginner (16 reputation)
Group: Forum Members
Posts: 16, Visits: 177
Thanks for the tip(s) guys. The day job is taking over at the moment so I'll give it a try soon...

BTW, it would be really helpful to have a "recipe" book of such topics for SF noobs like myself (you know the kind of thing, like the o'reilly books).

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.5K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Glad the headache is gone...that is never fun.
Trent Taylor
Trent Taylor
StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)StrataFrame Developer (10K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 6.9K
Ah...yeah, thanks Greg.  That is correct...and a very important step BigGrin  I was trying to answer the forum questions last night with a pounding headache...stupid I know Blush .... but today...headache gone and back to work BigGrin
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.5K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
You do not have to actually have the field strong-typed through the BO mapper. Let assume that you want to create an alias field or produce a custom field via your query, then even without creating a custom property on the BO you can access that field through the Item property on the BO. The field will exist in the internal data table but it will just not have a strong-typed property. So you could then create a custom property to access it if the need exists.




There are about a million bloody ways to access data with SF. I'm constantly amazed. I hadn't thought of this way at all....Blink
Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.5K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
1)Create the BO on the table.

2)Use a stored procedure to populate the BO that has all the columns in the source table plus joins on the three FKs so I can extract the Name value associated with each FK value. This will give me three extra columns: Name1, Name2 and Name3.

3)I was then going to create three custom fields in my BO called (you guessed it) Name1, Name2 and Name3.





Just one more step:



4. Override the GetCustomBindablePropertyDescriptors method to include each of the custom properties that you want to be bindable. There is info about this in help (I think). If you have trouble, I'll post an example.





Note that if your custom properties are readonly, then the BO will never enable them for editing (assuming normal SF binding).



You might also want to track when you call the fill method that fills the BO with the FK names, so you can gracefully handle (or informatively throw an exception) if you access on of the properties when those extra columns are in the data table.
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