Get a Jumpstart with our Sample Apps
Results 1 to 9 of 9

Thread: using list populate and search together

  1. #1
    VAR Pat Bremkamp's Avatar
    Real Name
    Pat Bremkamp
    Join Date
    Apr 2000
    Location
    Oregon, USA
    Posts
    2,536

    Default using list populate and search together

    I'm looking for a way to combine the JSON populate technique with a list search.

    We have a history of over 7000 inspections with about 1000 active at any one time. Our app design is to start with a searchable list (in a list control), select a project, then go to other areas to work on it. But, obviously, it takes way to long for a list of 7000 projects to get formatted and listed. We have identified 15 fields that are important to be able to search on, and that search needs to include all jobs in the history. So, we use an Xbasic callback and the "populate" technique to assemble the list in JSON and that is good for up to 500 projects in an acceptable time.
    We have hit on the following layout:
    list_search.png
    In the upper right corner of the pic, the user selects a list type, such as work list, full list, active only, etc. and a record limit, gets the list, then does the search. But, of course, the search only searches the list selected.

    I'm looking for a way to combine the list search with the list type and do them together.

    Thanks.
    Pat Bremkamp
    MindKicks Consulting

  2. #2
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    6,195

    Default Re: using list populate and search together

    Is the List Type and Record Limit Server-side?
    And the Search Client-Side?

  3. #3
    VAR Pat Bremkamp's Avatar
    Real Name
    Pat Bremkamp
    Join Date
    Apr 2000
    Location
    Oregon, USA
    Posts
    2,536

    Default Re: using list populate and search together

    Yes, the list type and record limit are in an Xbasic callback called in the onChange event of the list type dropdown. I've tried the search both ways...currently set to server side. In the grid there are onSearch and beforeSearch events but I can't find those for the list control.
    Last edited by Pat Bremkamp; 10-15-2017 at 10:42 AM.
    Pat Bremkamp
    MindKicks Consulting

  4. #4
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    6,195

    Default Re: using list populate and search together

    and that search needs to include all jobs in the history
    So the search needs to go against the 7,000 inspections.

    Do you want to search against 7,000 inspections and then, from those results, select a subset based on List Type and record limit?

  5. #5
    VAR Pat Bremkamp's Avatar
    Real Name
    Pat Bremkamp
    Join Date
    Apr 2000
    Location
    Oregon, USA
    Posts
    2,536

    Default Re: using list populate and search together

    Yes ... you are better at explaining it than I am!

    I suppose that I could get the search values using e.dataSubmitted and add them to the sql in the callback, but I was hoping to avoid all that code if Alpha has already done the work.

    Pat
    Pat Bremkamp
    MindKicks Consulting

  6. #6
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    6,195

    Default Re: using list populate and search together

    I think you could use this... have a look at the optional Xbasic function...

    https://www.alphasoftware.com/docume...t%20Method.xml

    Since you're using Server-side search, you can include an Xbasic function in .searchList()

    Your List Search definition and details are in e.searchDefinition.

    All your Search Controls and values... and UX Detail View Controls and values... are in e.tmpl.request.Variables.V.R1.

    If you wanted to use State Variables... they'd be found in e.tmpl.request.Variables._state.

    Once you're in your Xbasic function... you can adjust the filter in e.searchDefinition... adding in your List Type criteria, row limit, etc... and the rows returned will reflect everything you've set.
    Last edited by Davidk; 10-15-2017 at 03:09 PM.

  7. #7
    VAR Pat Bremkamp's Avatar
    Real Name
    Pat Bremkamp
    Join Date
    Apr 2000
    Location
    Oregon, USA
    Posts
    2,536

    Default Re: using list populate and search together

    That looks very promising if I can get it to work. Right now, I click the button and nothing appears to happen. It does not appear that the Xbasic function is getting called.

    The only place I see the .searchList() function is in the onClick event of the "search" button. So, I set it up this way:
    {dialog.object}.getControl('JOBLIST').searchList({searchMode:'serverSide',xbasicAfterFilterCompute:"pickListType"});

    Right now, I'm just trying to look at the alpha search definition so I can figure out how to include it. My Xbasic function is
    function pickListType as v (e as p)
    ... some stuff ...
    dim alphaFilter[0] as p = e.searchDefinition
    dim sql as C
    sql = e._state.basesql 'from onDialogInitialize
    dim json as c
    json = ""
    dim js as c
    js = ""
    dim typePicked as C = alltrim(e.dataSubmitted.listType)
    select
    case typePicked = "SJ" 'selected job
    sql = sql + "WHERE p.PROJECT_NUMBER = :argJobno "
    case typePicked = "WL" 'employee work list
    sql = sql + "WHERE p.ASSIGNED_EMPLOYEE = :argULINK "
    sql = sql + "AND p.CURRENT_ACTIVITY BETWEEN 10 AND 82 "
    sql = sql + "ORDER BY p.PROJECT_NUMBER "+sd+" LIMIT :argLimit"
    case typePicked = "FL" 'full list
    sql = sql + "ORDER BY p.PROJECT_NUMBER "+sd+" LIMIT :argLimit"
    case typePicked = "AA" 'all active
    sql = sql + "WHERE p.CURRENT_ACTIVITY BETWEEN 10 AND 82 "
    sql = sql + "ORDER BY p.PROJECT_NUMBER "+sd+" LIMIT :argLimit"
    case typePicked = "CA" 'client can work on these
    sql = sql + "WHERE p.CURRENT_ACTIVITY IN (23,70,81) "
    sql = sql + "ORDER BY p.PROJECT_NUMBER "+sd+" LIMIT :argLimit"
    case typePicked = "AN" 'active and has advise or deficient items
    sql = sql + "WHERE p.CURRENT_ACTIVITY BETWEEN 10 AND 82 "
    sql = sql + "(SELECT COUNT(*) FROM project_lines l WHERE l.PROJECT_NUMBER = p.PROJECT_NUMBER AND l.LINE_STATUS IN ('Advise','Deficient')) > 0 "
    sql = sql + "ORDER BY p.PROJECT_NUMBER "+sd+" LIMIT :argLimit"
    case else
    hasError = .t.
    errorMsg = "Could not change list type"
    end select
    if hasError = .F.
    if cnx.open("::name::nfn")
    if cnx.execute(sql,args)
    crs = cnx.ResultSet
    json = crs.ToJSONObjectSyntax()
    json = strtran(json,crlf(),"," + crlf())
    json = "[" + rtrim(json,",") + "]"
    js = "var lObj={dialog.object}.getControl('JOBLIST');"+crlf()
    js = js+"var _data="+json+crlf()
    js = js+"lObj.populate(_data);"
    cnx.FreeResult()
    else
    hasError = .T.
    errorMsg = "Could not execute query"
    end if
    cnx.close()
    else
    hasError = .T.
    errorMsg = "Could not connect to the database"
    end if
    end if
    if hasError = .F.
    pickListType = js
    else
    pickListType = "alert(errorMsg);"
    end if
    end function
    Pat Bremkamp
    MindKicks Consulting

  8. #8
    VAR Pat Bremkamp's Avatar
    Real Name
    Pat Bremkamp
    Join Date
    Apr 2000
    Location
    Oregon, USA
    Posts
    2,536

    Default Re: using list populate and search together

    Could not access the Xbasic function for some reason, so I switched the search button to call the callback function, got the search values there, built the where clause, run the sql and it is working.
    Pat
    Pat Bremkamp
    MindKicks Consulting

  9. #9
    VAR Pat Bremkamp's Avatar
    Real Name
    Pat Bremkamp
    Join Date
    Apr 2000
    Location
    Oregon, USA
    Posts
    2,536

    Default Re: using list populate and search together

    Well duh! That feature is not available until release 4642. I'm not on that release yet!
    Pat Bremkamp
    MindKicks Consulting

Similar Threads

  1. Re-Populate Lookup List
    By JetLi in forum Mobile & Browser Applications
    Replies: 2
    Last Post: 04-13-2016, 09:21 AM
  2. Populate search list based on main grid query
    By jwilliamson in forum Mobile & Browser Applications
    Replies: 0
    Last Post: 11-24-2015, 06:34 PM
  3. Populate UX from a List
    By Ronald Anusiewicz in forum Mobile & Browser Applications
    Replies: 12
    Last Post: 10-13-2015, 01:36 PM
  4. Replies: 1
    Last Post: 08-07-2015, 02:38 PM
  5. Pre-populate search fields on grid
    By Antony in forum Application Server Version 11 - Web/Browser Applications
    Replies: 3
    Last Post: 05-09-2012, 10:45 AM

Posting Permissions

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