Displaying field from a joined table


Author
Message
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
Do custom field properties behave differently from bomapper field properties if the fill method returns no records and is that what we are testing for and would that need to be handled if there were no customer field props?

If you are just pulling from thr CurrentRow, then no.  They behave just like any of the other properties.  Obviously if you add additional logic past just retrieving the value then you have need to take this into account.  But otherwise it will behave like any other field property.

Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
I guess what I meant was - since this tests for the rowcount it is basically testing for an empty cursor.  So if I have a parameterized query that returns no records, for example, there is a possibility the cursor will be empty. 

I understand Greg's suggestion for a try - catch so you can have fill methods that do not use that joined column, but my question is :

Do custom field properties behave differently from bomapper field properties if the fill method returns no records and is that what we are testing for and would that need to be handled if there were no customer field props?

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
Trent, should one always test for the count in using customer field props, then? 

Honestly I only do this when there is the potential for this to occur.  If this should never occur based on my logic, then I don't do this so I get an error message preventing any other downstream errors.

Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
Trent, should one always test for the count in using customer field props, then? 
Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
Hi Greg

Thanks for the heads up.  in this case I'm joining to another table in the stored proc so I think there will always be a column.  Since I'm doing a left join, I'm testing for null in the initial select and returning a "NO PO NUMBER" string in the case of a null value.

This exercise was a reminder, however, to actually look at the test data before making ***-umptions about the results. (hey that's cool, I put in a hyphen to emphasize the old trope about assumptions and the parser censored me ) The ORDERS table in the Strataframe Sample Data is mostly blank in the or_ponumber field and I really suspected I was having a series of senior moments when I finally got the binding to work, did my thing to check nulls and still ended up with a blank textbox on the screen and a blank in the field in the currentview.  Thought I may have forgotten everything I knew about SQL. 

But of course I was getting just what I asked for - I just didn't know I'd asked for a column where most of the values were blank Smile

I am going to test now to see if an exception is thrown if there is no data at all in the cursor as I'm starting to think the gist of your suggestion may be that custom props do not behave like bomapper props when the query pulls an empty recordset. 

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
Or just test on the count:

If Me.Count < 0 Then
    '-- Return your field
End If

Smile

Greg McGuffey
Greg McGuffey
Strategic Support Team Member (3.4K reputation)
Group: Forum Members
Posts: 2K, Visits: 6.6K
Charles,



Glad you got it going! Here are some other things to consider when using custom properties that will reference a "special" field in the data table:



- You probably should check for a current row...if there is no current row, the .Item("orderpo") will throw an exception

If Me.CurrentRowIndex < 0 Then

'-- Return a default value

End If


- You also probably need to handle the case were the column isn't in the table. I.e. what if you have a fill that doesn't include the "orderpo" column, you forget and reference it anyway...boom. You would just use a Try/Catch and throw an exception that will quickly let you know what you forgot.



Just a couple of things that I spent too much time on in the beginning, thought I'd share BigGrin
Charles R Hankey
Charles R Hankey
Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)Advanced StrataFrame User (940 reputation)
Group: Forum Members
Posts: 524, Visits: 30K
If you intend to bind this field to anything, you will need to override the GetCustomBindablePropertyDescriptors method and return a ReflectionPropertyDescriptor.  There are a ton of posts and docs regarding this, but if you get stuck just let me know.

Thanks to a some posts between Greg and Peter Jones I figured out the array and the sample in the tutorial make more sense

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

'-- Create and return a new array of FieldPropertyDescriptor

' objects that contains the ReflectionPropertyDescriptor

' for the cust_fullname field.

Return New MicroFour.StrataFrame.Business.FieldPropertyDescriptor() { _

New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _

"cust_fullname", GetType(CustomersBO)), _

New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _

"orderpo", GetType(CustomersBO))}

End Function

Once the project is rebuilt the field appears in the enumeration for binding field and displays just what I need.  Of course the field is read only, as it should be.

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
Returning a field or column from a joined table is a must in the disconnected world.  So in order to interact with it, just create the custom property and then...as you discovered...call the Me.CurrentRow.Item("MyField") property on the return an you have it. 

Trent, thanks for the explanation.

Charles, I am glad you find it.  In fact I was not sure on the right answer since I have not done that yet, but I knew it has something to do with the return value of the custom field property, now I know Tongue

Edhy Rijo

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
Charles,

It looks like you got it going.  I didn't work this weekend so I wasn't out on the forum much.  But you did get it figured out.  Returning a field or column from a joined table is a must in the disconnected world.  So in order to interact with it, just create the custom property and then...as you discovered...call the Me.CurrentRow.Item("MyField") property on the return an you have it.  If you intend to bind this field to anything, you will need to override the GetCustomBindablePropertyDescriptors method and return a ReflectionPropertyDescriptor.  There are a ton of posts and docs regarding this, but if you get stuck just let me know. Smile

This framework, this forum and this community ROCKS !!

I agree BigGrin Thanks for your kind words...and thanks for your input, Edhy!  I know that Charles appreciated it!

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