How to display empty dates in ListView?


Author
Message
Larry Tucker
Larry Tucker
StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)
Group: StrataFrame Users
Posts: 69, Visits: 308
Well, I'm back to SF after a few years and some other adventures (an Ironspeed web app, some data mining experience...) and am converting a VFP (VPME) application.  (Hello to some old VPME'ers out there like Edhy).  I'm really liking the core SF functionality but have some questions around the fringes.

So my first question concerns displaying empty dates.  I see that the DateBox is now the preferred way of editing dates and it has an EmptyValue property for trapping a place holder value (like '1/1/1800') and displaying it as blank. 

What is the best way to trap and hide these place holder dates in other places, such as in ListView columns?  I see I have two options to format a column:  Format String and PopulatedThroughEvent.  I suspect the preferred way is to use PopulatedThroughEvent to trap the place holder date value and return a "" string.  Is that about right?  Any examples?

Thanks in advance,

Larry
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Larry,
Welcome back!!!

Well, StrataFrame handle this situation very easy via the "NULL Value Option" in the "Custom Field Properties" in the Business Object Mapper.  Just select a null option like "Return Altername on Null" and set it to the empty date value like this: New Date(1800,1,1) so when you get a Null date from SQL Server, you are actually getting 1/1/1800 and SF will translate that for you in every SF control including the ListView, so you don't have to anything else.
http://forum.strataframe.net/Uploads/Images/3d9951a5-1f50-43bb-a24d-ceca.png

Edhy Rijo

Larry Tucker
Larry Tucker
StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)
Group: StrataFrame Users
Posts: 69, Visits: 308
Hi Edhy,

It is good to be back.  And I see you've really mastered SF... and are continuing to help a lot in the forum.

This is just what I needed.  Excellent.  Thanks.

Larry
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Larry,
Larry Tucker (3/2/2012)
... I see you've really mastered SF... and are continuing to help a lot in the forum.


Mastered SF, No really, still have a lot to learn.  Just that by using it almost every day you get more familiar with the tools Smile

I noticed you mentioned IronSpeed, if you don't mind, I would like to know about your experience with it, I will send you a private message with my phone.

Edhy Rijo

Larry Tucker
Larry Tucker
StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)
Group: StrataFrame Users
Posts: 69, Visits: 308
Edhy,

Was nice chatting just now. 

As for the display issue, I think I've got the BO translation working but it still shows in the ListView as 1/1/1800.

(Am trying to upload a screen shot here).

Will keep poking around at the problem...

Larry
Edhy Rijo
E
StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)StrataFrame VIP (4.6K reputation)
Group: StrataFrame Users
Posts: 2.4K, Visits: 23K
Hi Larry,
Here is what you need to do to get your empty dates to be shown as blank in the listview:
  • In the ListView Population Setting, set the "Population Type" of the date column to be "PopulatedThroughEvent
http://forum.strataframe.net/Uploads/Images/a10854a9-10cf-487f-bc58-8067.png
  • Create a handle for the Listview.RowPopulating and enter code like this:

    Private Sub ListView1_RowPopulating(e As MicroFour.StrataFrame.UI.Windows.Forms.RowPopulatingEventArgsHandles ListView1.RowPopulating
         Using bo As bizCustomers = CType(e.BusinessObject, bizCustomers)
             If bo.cust_Created = #1/1/1800# Then
                 e.Values(2).DisplayValue = String.Empty
             End If
         End Using
     End Sub

That should take care of this issue. Also, if you will be manipulating the data in the listview, I prefer to add an instance of the BO, fill the data of the BO, then requery the ListView using the
BusinessCloneDataType.ClearAndFillFromDefaultView as below and set the ListView.AutoNavigateToSelectedRecord = True

    Private Sub ListView1_ListPopulating(e As MicroFour.StrataFrame.UI.ListPopulatingEventArgsHandles ListView1.ListPopulating
         e.Parameters(0).Value = Me.BizCustomers1
         e.Parameters(1).Value = MicroFour.StrataFrame.Business.BusinessCloneDataType.ClearAndFillFromDefaultView
     End Sub



Edhy Rijo

Larry Tucker
Larry Tucker
StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)
Group: StrataFrame Users
Posts: 69, Visits: 308
Hi Edhy,

Thank you for following up about the display issue.  That solved it.

BTW, how are you formatting the code and uploading the screen shots in your replies?  They are very clear. Is there a Forum guide somewhere that explains this?

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

Glad it is working for you now.

Larry Tucker (3/6/2012)
BTW, how are you formatting the code and uploading the screen shots in your replies?  They are very clear. Is there a Forum guide somewhere that explains this?

I use Firefox browser and when replying simply click the "IF Code" and select "Code Snipped", then I copy and paste my code between the codesnippet tags and to keep it formatted properly, I have to add a carrier return at the end of each copied line, otherwise it would be pasted as a one line only.

See Sample Image:


         '-- Bypass this method when the form is being loaded.
         If Me.FormIsLoading Then
             '-- Clear the BO so no previous record are re-used
             '   This line is causing a problem with previously modified records.
             '   for now do not clear the BO.  8/12/2009
             Me.BizTransactionItemsStock1.Clear()

             ' ER 10/27/2010: Added the Requery to force the Edit Button cmdChangeActiveQtyAndStartValues
             ' to be enabled/disable properly.
             Me.lstItemsStock.Requery()
             Exit Sub
         End If


http://forum.strataframe.net/Uploads/Images/9e82e30b-8333-4c6b-b54c-5fe0.png


Edhy Rijo

Larry Tucker
Larry Tucker
StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)StrataFrame User (139 reputation)
Group: StrataFrame Users
Posts: 69, Visits: 308
Thanks Edhy,

Using Firefox helped me see the formatting codes in the text editor.  They were hidden in IE...

So here is my code (for various reasons I'm using 1/1/2200 to indicate an "open" ending date)...


Private Sub CoverageListView_RowPopulating(e As MicroFour.StrataFrame.UI.Windows.Forms.RowPopulatingEventArgs)
 Handles CoverageListView.RowPopulating
        Dim bo As CoverageBO
        bo = e.BusinessObject
        If bo.COV_END = #1/1/2200# Then
            e.Values(6).DisplayValue = String.Empty
        Else
            e.Values(6).DisplayValue = bo.COV_END.ToShortDateString
        End If
    End Sub


And here is the result showing blank "End Pop" column in the listview on a test screen...

http://forum.strataframe.net/Uploads/Images/e960cf1c-ff7a-4efe-9361-e8ac.jpg


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

I am glad you figured out, it looks good.  One thing I would change in your code is instead of using Dim bo As CoverageBO I would use the "Using...End Using" as posted in one of my sample code in previous posting in this thread just to avoid any possible memory leak by no disposing the bo object and keep in mind that this code will run for each created row in the listview, so with many records loaded, it could just bloat up at any point.


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