StrataFrame Forum

How to have datetime searchfields checked by default in Browse Dialog

http://forum.strataframe.net/Topic30852.aspx

By Charles R Hankey - 2/3/2012

I have 2 searchfields in my Browsedialog and have the defaults set for >= and <= Datetime.Today in their properties.

How do I make sure they are checked by default when the user brings up the BD? 

Thanks
By Trent L. Taylor - 2/3/2012

Set the InitialValue in the search field.  Another choice is to use an Enum, which you can still set the default value as well.  Just make the values of the enum line up with 0 or 1 for True and False.  I think that there is a sample of this somewhere in StrataFlix...I haven't look in a while.  But I KNOW that I have talked about this before BigGrin
By Charles R Hankey - 2/3/2012

 

I want the two datetime pickers checked by default so unless the user says otherwise they are part of the criteria.  Just tested and putting true in the intitial value has no effect
By Trent L. Taylor - 2/3/2012

I'm sorry, I was reading several posts and once and thought we were talking about a boolean.  Just a sec while I look at something.
By Charles R Hankey - 2/3/2012

I looked at the BD in the IniitializeSearchFields event but don't see anything tweakable there.  Can't see a controls collection or where we might have access to anything on the BD form after its components are initialized ( my favorite enhancemet request to BD is to decouple interface from data logic and give access to the browse dialog UI, even to completely designing the form and just bindiing to a collection of search fields )

Looks like that datepicker with the checkbox isn't touchable from the outside world.

Hope you have a trick up your sleeve on this one as default for my users is to have those boxes always checked but they still want to be able to uncheck them so without some access I'm going to need outside data input to decide on which view etc BD is going to use and build stuff about those two date fields into separate sps ... well, you get the idea. 

( solved my BD / Extra column problem using my TVP trick as posted in User Contributed etc.  Works great.  )
By Edhy Rijo - 2/3/2012

Hi Charles,

Handle the BD.InitializeSearchFields event and add your default values to the 2 fields in the BD.  Here is a sample from one of my projects:

        Private Sub FirstUseImportBrowseDialog_InitializeSearchFields(ByVal sender As System.ObjectByVal e As System.EventArgsHandles MyBase.InitializeSearchFields
             Me.SearchFields("TransactionType").InitialValue = Enumerations.TransactionType.FirstUseImport
         End Sub


In above sample, the "TransactionType" field is of type enumeration, so in your case you may need to convert the date to string.
By Charles R Hankey - 2/6/2012

I must not be explaining the problem very well.  In a datetime picker as used by the BD, the initialvalue - which can be set in the properties as design time - is a datetime.  What I want to change is the checkmark that says "use this datetime as part of the search criteria."  By default, if the user does not check it, it will not be used.  This is not the behavior I want. 

I haven't heard back from Trent so I think I'm on my own on this one.
By Edhy Rijo - 2/6/2012

Hi Charles,

Charles R Hankey (2/6/2012)
I must not be explaining the problem very well.


I believe you are under some pressure and must not be reading my responses clearly BigGrin

If you set the default value of the 2 date fields in the BD InitializeSearchFields() event, you will get the result you want as shown in the image below.

        Private Sub ServiceCallsBrowserDialog_InitializeSearchFields(sender As System.Object, e As System.EventArgsHandles MyBase.InitializeSearchFields
             Me.SearchFields("CallDateFrom").InitialValue = Now.Date
             Me.SearchFields("CallDateto").InitialValue = Now.Date
         End Sub


http://forum.strataframe.net/Uploads/Images/1b5f3d8f-60b3-4096-bbe0-7423.png
Enjoy!!!  Cool
By Charles R Hankey - 2/6/2012

YOU ARE MY HERO !

This did the trick!  I had the date set in the property sheet and incorrectly assumed it was setting the date in the control . ( suspect it wasn't doing anything )

But this does exactly what I need and is GREATLY appreciate !

Thanks again
By Edhy Rijo - 2/6/2012

Charles R Hankey (2/6/2012)
YOU ARE MY HERO ! This did the trick!...

Hmmm, I could have been your hero since 2/3/2012 Tongue  Just kidding Charles, I am glad you pass these issues and your application is looking good again.

My approach since working with frameworks is to work with the framework, not against it!!!!