Alpha Video Training
Results 1 to 16 of 16

Thread: Dropdown list filter

  1. #1
    Moderator Steve Workings's Avatar
    Real Name
    Steve Workings
    Join Date
    Apr 2000
    Location
    The Dreaded Chair
    Posts
    5,570

    Default Dropdown list filter

    Is anyone else having the problems I'm having with dropdown filters?

    I have several grid variables where the dropdown list for the variable is to be filtered on the value of a previously-filled variable.

    For instance:

    with tmpl.field_info[8]
    .Fieldname = "Event_Timezone"
    .Scope = "Local"
    .DisplayFormat = ""
    .DisplayUnFormat = ""
    .Type = "C"
    .Updateable = .t.
    .Table_Alias = "events"
    .FieldToUpdate = "Event_timezone"
    .Varname = "EVENT_TIMEZONE"
    .NullIfBlank = .f.
    .Controltype = "DropDownBox"
    .DropdownBox.InLineStyle = ""
    .DropdownBox.Type = "Dynamic"
    .DropdownBox.StyleFieldIfError = .t.
    .DropdownBox.ErrorInLineStyle = ""
    .DropdownBox.Size = 1
    .DropdownBox.selectStyle = "Single"
    .DropdownBox.NotInListRule = "Do Nothing"
    .DropDownBox.Datasource = "DBF-Table"
    .DropDownBox.Table = "[PathAlias.ADB_Path]\TimeZones.dbf"
    .DropDownBox.DisplayValueField = "Zonecode"
    .DropDownBox.StoredValueField = "Zonecode"
    .DropDownBox.maxchoices = 0
    .DropDownBox.Filter = "ut(location) = UT([varC-"EVENT_TIMEAREA])"
    .Column.Hide = .t.
    end with

    The dropdown list, however, is empty.

    I've tried variants of this for 2 hours, so thought I'd put it out here for help.

    TIA

    - Steve

  2. #2
    Alpha Software Employee Selwyn Rabins's Avatar
    Real Name
    Selwyn Rabins
    Join Date
    Mar 2000
    Location
    Boston, MA
    Posts
    5,272

    Default RE: Dropdown list filter

    i would really need to see your app, but this line is wrong:

    .DropDownBox.Filter = "ut(location) = UT([varC-"EVENT_TIMEAREA])"


    what is varC-"event_timearea?


    assuming you had some variable called (say) vEventTimeArea, the correct syntax would be

    .DropDownBox.Filter = "ut(location) = " + quote(vEventTimeArea)

  3. #3
    Moderator Steve Workings's Avatar
    Real Name
    Steve Workings
    Join Date
    Apr 2000
    Location
    The Dreaded Chair
    Posts
    5,570

    Default RE: Dropdown list filter

    I'm just using the filter builder in the grid component. It works just fine in the dialog component, but the grid component seems to be a problems.

    For instance:

    In a dialog component, I can specify a filter of

    Location = ?

    and fill in the genie to specify what the "?" is about. Works just fine.

    The filter looks like this:

    .DropDownBox.Filter = "Location = [varC-"vTimeZoneArea]"

    Do the same thing in the grid component, with Event_TimeArea as a previously-filled variable on the grid, and get the filter I showed you and an empty dropdown list.

    The filter looks like this:

    .DropDownBox.Filter = "Location = [varC-"EVENT_TIMEAREA]"

    Should I be specifying something other than a variable in the grid filter? The only other option is a constant.

    Thanks.

  4. #4
    Alpha Software Employee Selwyn Rabins's Avatar
    Real Name
    Selwyn Rabins
    Join Date
    Mar 2000
    Location
    Boston, MA
    Posts
    5,272

    Default RE: Dropdown list filter

    steve

    I think you have run into a bug.

    Only the dialog component supports 'cascading' dropdowdown boxes. A cascading dropdownbox is one where a selection in one drop down box causes the form to submit and the selection in another dropdown box to automatically adjust based on the selection in the first dropdown box. (e.g. example 2.1 in the demo app).

    When you define a dropdown box in a dialog and you filter it based on the value in another dropdownbox on the dialog, a5 automatically writes the correct html to cause the form to submit itself (using javascript) when the selection in the first dropdown box occurs.


    Grid components do not allow for for this. The 'bug' is that the choice builder for the dropdown box gave you the option of using a ? in the filter expression. It should not have. This option should have been restricted to Dialog components. The 'bug' occured because this choice builder is common to both the grid and dialog builder.

  5. #5
    Moderator Steve Workings's Avatar
    Real Name
    Steve Workings
    Join Date
    Apr 2000
    Location
    The Dreaded Chair
    Posts
    5,570

    Default RE: Dropdown list filter

    So there's no workaround or other solution? I have a few grids built with the expectation I'd be able to solve the problem. I'd hate to have to redo 'em all as dialog components.

    - Steve

  6. #6
    Alpha Software Employee Selwyn Rabins's Avatar
    Real Name
    Selwyn Rabins
    Join Date
    Mar 2000
    Location
    Boston, MA
    Posts
    5,272

    Default RE: Dropdown list filter

    are these drop down boxes in the "search" part of your grid?

    i suspect that a clever programmer could work around the problem by changing to a free form layout and then manually adding the javascript necessary to autosubmit the search part of the form.

    if you looked at the html that the dialog component generated for an dropdown box that causes the dialog form to auto-submit, you would see how to do it.

  7. #7
    Guest
    Real Name
    martin horzempa
    Join Date
    Aug 2004
    Posts
    28

    Default RE: Dropdown list filter

    i have tried desperately to set the onchange property
    in a grid dropdown and still haven't been able to do it
    i have 2 forms that i would like to execute some javascript
    when the user changes the value of the dropdown . the freeform part allows me to be able to do everything EXCEPT set the value of the onchage property of the dropdown.
    i have also attempted to to do the same with the onload event
    by attempting to set the on change event for the dropdown when the form loads ,
    but still no luck the html generated always is the same

    ONCHANGE = ""

    the only way i have been able to work around this is genterate the options in a dynamic dropdown and then cut and paste this into a separate form outside of the grid
    and change the dropdown to a textbox and change the value with some javascript - seems like a lot of work when
    all we need is a new property in the grid builder for a dropdown -- onchange="" and then its just a couple of keystrokes and you have it finished using the freeform layout option

    i would be most grateful if you could help
    regards
    martin

  8. #8
    "Certified" Alphaholic
    Real Name
    Peter Wayne
    Join Date
    Apr 2000
    Posts
    1,728

    Default RE: Dropdown list filter

    martin,
    what code did you use in your document's onload event? it should be possible to change the event handling of any object through javascript; it shouldn't matter that it is part of a grid.
    - peter

  9. #9
    Guest
    Real Name
    martin horzempa
    Join Date
    Aug 2004
    Posts
    28

    Default RE: Dropdown list filter

    thanx for the reply Peter

    i still cant seem to make it work
    i have tried it every way that i can think of

    here are three of the latest attempts



    this code is called with the onload event for the page


    // reset the on change event for the CC type dropdown to allow for clearing the CC number field if the user changes the CC Type
    var fcct = document.getElementsByName("V.R1.PAYMENT_TYPE");
    var fccta = fcct[0]
    // fcct[0].onchange = "clearCCNumber()";
    // document.TordCC.elements[1].onchange = "clearCCNumber()";
    // document.TordCC.fcca.onchange = "clearCCNumber()";

    when the page is generated it still has the onchange property set to ""

    if you could enlighten me as to what i am doing wrong i would be most grateful

    thanx in adavnce
    martin

  10. #10
    "Certified" Alphaholic
    Real Name
    Peter Wayne
    Join Date
    Apr 2000
    Posts
    1,728

    Default RE: Dropdown list filter

    martin,
    when the code is generated and you "view source" for the page, you will see the code that is sent to the browser. that will include "b"onchange="""/b".
    the onchange code is changed by javascript. you won't see that when you look at the source. you can only tell that it happens by, say, putting an alert() in the function called by onload to see what the onchange actually is, or putting an alert in the clearCCNumber() code to see if it is being called.
    -peter

  11. #11
    Guest
    Real Name
    martin horzempa
    Join Date
    Aug 2004
    Posts
    28

    Default RE: Dropdown list filter

    thanks again peter
    this i wasn't sure about but just to make sue i use
    alert boxes in the functions to make sure at least thay are called and execute.

    in the TordCC.a5w page i have
    in the header section:
    "script type="text/javascript" language="javascript" src="CCValidate.js"""/script"

    in the body:
    "body onload="breaktele()"" thsi calles the function

    the functions breaktele() and clearCCNumber()are in CCvalidate.js

    here are the two functions

    function breaktele() // get the telephone numbers and break them up and place the parts into the telparts
    {
    var fdaytel = document.getElementById("V.R1.PAYMENT_TELE1");
    var daytel = fdaytel.value;
    // alert("in breaktele- daytel---" + daytel);

    document.TordCC.elements[17].value = daytel.substring(0, 3);
    document.TordCC.elements[18].value = daytel.substring(4, 7);
    document.TordCC.elements[19].value = daytel.substring(8, 12);

    var falttel = document.getElementById("V.R1.PAYMENT_TELE2");
    var alttel = falttel.value;

    document.TordCC.elements[21].value = alttel.substring(0, 3);
    document.TordCC.elements[22].value = alttel.substring(4, 7);
    document.TordCC.elements[23].value = alttel.substring(8, 12);

    // clearCCNumber()

    // reset the on change event for the CC type dropdown to allow for clearing the CC number field if the user changes the CC Type
    var fcct = document.getElementsByName("V.R1.PAYMENT_TYPE");
    var fccta = fcct[0]
    // fccta.onchange = "clearCCNumber()";
    // document.TordCC.elements[1].onchange = "clearCCNumber()";
    // document.TordCC.fccta.onchange = "clearCCNumber()";


    }


    function clearCCNumber()
    {
    // Force user to re-enter credit card number if the credit card type is changed
    // onChange event on the credit card type select box
    //alert("Got to clearCCNumber")
    document.TordCC.elements[2].value = "";

    }


    and they are both called and can be chained but it has no effect
    am i useing the right method for this operation and the right syntax to get the job done??????


    thanx again for your assistance

    blueintheface
    martin

  12. #12
    Guest
    Real Name
    martin horzempa
    Join Date
    Aug 2004
    Posts
    28

    Default RE: Dropdown list filter

    ok peter i attempted to get an alert box with the onchange
    value

    added these two alerts

    alert("on change for dropdown---" + fccta.onchange);

    alert(" after change attempt--on change for dropdown---" + fccta.onchange);


    get the same response fo both:

    on change for dropdown---
    function(event){
    }



    after change attempt--on change for dropdown---
    function(event){
    }


    i may not have formatted the request properly

    but i got an undefined when i used

    alert("on change for dropdown---" + fccta.onchange.value);
    and the same thing for

    alert("on change for dropdown---" + fccta.onchange.text);

    its as clear as mud to me

    thanx again

    indesperateneedofminoxidil
    martin

  13. #13
    "Certified" Alphaholic
    Real Name
    Peter Wayne
    Join Date
    Apr 2000
    Posts
    1,728

    Default RE: Dropdown list filter

    martin,
    i could be wrong about this, but i think you have to change

    // reset the on change event for the CC type dropdown to allow for clearing the CC number field if the user changes the CC Type
    var fcct = document.getElementsByName("V.R1.PAYMENT_TYPE");
    var fccta = fcct[0]
    // fccta.onchange = "clearCCNumber()";
    // document.TordCC.elements[1].onchange = "clearCCNumber()";
    // document.TordCC.fccta.onchange = "clearCCNumber()";

    to

    // reset the on change event for the CC type dropdown to //allow for clearing the CC number field if the user changes //the CC Type
    var fcct = document.getElementsByName("V.R1.PAYMENT_TYPE");
    var fccta = fcct[0];
    fccta.onchange = clearCCNumber;

    i *think* that the function name should not be in quotes. i'd have to experiment to be sure; i get confused easily with javascript syntax.
    also, since there is probably only one payment type per row, you should be able to make it

    // reset the on change event for the CC type dropdown to //allow for clearing the CC number field if the user changes //the CC Type
    var fccta = document.getElementById("V.R1.PAYMENT_TYPE");
    fccta.onchange = clearCCNumber;

    good luck,
    peter

  14. #14
    "Certified" Alphaholic
    Real Name
    Peter Wayne
    Join Date
    Apr 2000
    Posts
    1,728

    Default RE: Dropdown list filter

    martin,
    here's a simple example without a grid, showing the proper syntax for changing the onchange event of a select control in javascript:


    "head"
    "meta name="generator" content="Alpha Five HTML Editor""
    "title""/title"
    "script language="javascript" type="text/javascript""
    function ccTypeChange(){
    ccnmbr=document.getElementById("ccnumber");
    ccnmbr.value="";
    }

    function init(){
    cct=document.getElementById("cctype");
    cct.onchange=ccTypeChange;
    }

    window.onload=init;
    "/script"
    "/head"
    "body"
    Credit Card type: "select id=cctype"
    "option value=amex selected "American Express"/option"
    "option value=VISA"Visa"/option"
    "option value=MSTR"Mastercard"/option""/select""br"
    Credit Card number:
    "input id=ccnumber size=14""/body"


    note also that i put a "window.onload=init" in the "head" section. Alpha Five puts its own ""body"" in when you publish the page, and if you're not careful your "body onload" can be conflict with A5's. Putting the onload code in the "head" section resolves any potential conflict.

    - peter

  15. #15
    Guest
    Real Name
    martin horzempa
    Join Date
    Aug 2004
    Posts
    28

    Default RE: Dropdown list filter

    ok Peter
    youdaman
    YUODAMAN
    You are the man
    and i have my sanity back
    the syntax :

    fccta.onchange = clearCCNumber;

    did the trick

    i cant tell you how much your help
    has meant
    thanx again

    martin

  16. #16
    Guest
    Real Name
    martin horzempa
    Join Date
    Aug 2004
    Posts
    28

    Default RE: Dropdown list filter

    thanx for the tips
    i will most definitely use this method for calling the onchange and on load scripts scripts


    thanx again for all of your help

    regards
    martin

Similar Threads

  1. Date Based dropdown list filter does not filter
    By Steve Bovino in forum Web Application Server v6
    Replies: 17
    Last Post: 10-15-2005, 08:36 AM
  2. DropDown List
    By gboot1tc in forum Web Application Server v6
    Replies: 4
    Last Post: 09-23-2005, 03:51 AM
  3. dropdown list on forms
    By Jay Talbott in forum Alpha Five Version 5
    Replies: 2
    Last Post: 12-01-2004, 01:01 AM
  4. Dropdown record list box -- ??
    By Doug Martin in forum Alpha Five Version 5
    Replies: 6
    Last Post: 07-19-2004, 01:35 PM
  5. dropdown list
    By tony cox in forum Alpha Five Version 4
    Replies: 6
    Last Post: 03-13-2003, 02:32 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •