Show lookup description data in a grid or listview


Author
Message
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Edhy,

It is always nice to get other peoples perspectives as I am on the other side of the fence when it comes to the ListView vs. the Grid.  I think that grids have many good uses, but for read-only data, I think they produce too much overhead and too many potential bugs since the grid is so versatile and has so many properties and different types of functionality to meet a wide-spectrum of needs.

We tried to design our ListView so that read-only data could be loaded very easily.  Simply create the columns, determine if the column will be pulled from a field in the BO or populated through an event.  For example, you can use the approach that Tim pointed out by creating a custom property...or you can create a scalar method, create a fill method that includes the columns you need, etc. then indicate that column will be "Populated Through Event."  You will then handle the RowPopulating event of the ListView and set the column information for each row:

RowPopulatingEvent
With CType(e.BusinessObject, MyBO)
    e.Columns(1).DisplayValue = CType(.CurrentRow.Item("MyIncludedField"), String)

    '-- OR

    e.Columns(1).DisplayValue = .MyCustomProperty

    '-- OR

    e.Columns(1).DisplayValue = SomeBO.ExecuteAScalarMethod()

    '-- OR

    e.Columns(1).DisplayValue = (.CalcField1 + .CalcField2).ToString("n0")


EndWith

As you can see, there are many different ways to pull in data for a column that may come from another table or may be a calcualted field.

Tim Dol
Tim Dol
Advanced StrataFrame User (666 reputation)Advanced StrataFrame User (666 reputation)Advanced StrataFrame User (666 reputation)Advanced StrataFrame User (666 reputation)Advanced StrataFrame User (666 reputation)Advanced StrataFrame User (666 reputation)Advanced StrataFrame User (666 reputation)Advanced StrataFrame User (666 reputation)Advanced StrataFrame User (666 reputation)
Group: Forum Members
Posts: 340, Visits: 1.4K
Edhy,

I usually create custom field properties on the business object to handle these situations. Refer to the StrataFrame help 'Adding Custom Field Properties'.  You can also use a database view.

Here is a sample of a custom field property:

<Browsable(False), _

BusinessFieldDisplayInEditor(), _

Description("SalesRep Name"), _

DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _

Public ReadOnly Property [SalesRepName]() As System.String

Get

Dim ef As New EmployeeFileBO()

ef.FillByPrimaryKey(Me.SalesRep)

If ef.Count = 1 Then

Return ef.LongName

Else

Return String.Empty

End If

ef.Dispose()

End Get

End Property

 

You will need to add a property descriptor if you want to bind the custom field to a grid.

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

'-- Create and return a new array of FieldPropertyDescriptor

' objects that contains the ReflectionPropertyDescriptor

' for the Licence Description field.

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

New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _

"CustServiceRep", GetType(ClientFileBO))}

End Function.

 


Edhy Rijo
E
StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)StrataFrame VIP (6.4K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi,

I am working on a form with a grid or listview which will show data from a related table as a lookup and I would like to show a descritive fields instead of the Foreing Key field value, how can I do this?

In the picture attached, the FK_Appliances in the Grid or Appliance in the List View are the ones I want to show the descriptive field instead of the FK value.

Also, since I am learning SF, I found that the creation of a ListView is a bit difficult than using a GridView for read only data, is there a way to show the grid with empty columns like in the ListView in order to cover the gray area of the grid?

Thanks!

Edhy Rijo

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