Alpha Video Training
Results 1 to 4 of 4

Thread: Filter Grid by Logged in User

  1. #1
    Member
    Real Name
    Miles Nolan
    Join Date
    Jan 2008
    Posts
    265

    Default Filter Grid by Logged in User

    Hi All

    Sure this is a simple one, but I have been struggling to find the answer.... so if anyone can help it would be greatly be appreciated....

    This is a Web App in V8.

    I have a Grid containing data for multiple customers, I want the customer to be able to login with there login and only see there data.

    therefore i need to filter the grid by the user login.

    Please HELP.

    Thanks

    Miles

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

    Default Re: Filter Grid by Logged in User

    This question has been covered many times before, so a search should yield lots of information.

    In a nutshell, use the user's login to get the ulink value and get the user's company Id from his/her people record. Stick that in a varaible in the URL or in a session variable. Then, in the grid you want to filter, create an argument based on the variable and filter the grid based on the argument.

    Works very well.

    Pat

  3. #3
    Member
    Real Name
    Miles Nolan
    Join Date
    Jan 2008
    Posts
    265

    Default Re: Filter Grid by Logged in User

    Hi Pat

    Many Thanks for your answer, I think i understand the principle however I am still unsure how to put it into practice...

    I have ticked the box in the security configuration sp per attachment image.

    Attachment 21413

    Then in my page that contains the grid, i have the following code.... I have highlighted the filter bit below...

    If you could tell me where I am going wrong it would be great... Thanks a Lot

    Miles



    <html>
    <head>

    <%a5
    Delete tmpl_Grd_Menu
    DIM tmpl_Grd_Menu as P
    tmpl_Grd_Menu = a5w_load_component("Grd_Menu")
    'Following code allows you to override settings in the saved component, and specify the component alias (componentName property).
    'Tip: Keep the componentName property short because this name is used in page URLs, and it will help keep the URLs short.
    'Each component on a page must have a unique alias (componentName property).
    with tmpl_Grd_Menu
    location = ""
    componentName = "Grd_Menu"
    end with
    '=======================================compute the HTML for the Component=======================================
    delete x_Grd_Menu
    dim x_Grd_Menu as p
    x_Grd_Menu = a5w_run_Component(tmpl_Grd_Menu)
    ?x_Grd_Menu.Output.Head.JavaScript
    ?x_Grd_Menu.Output.Head.CSS_Link
    %>

    <%a5
    Delete tmpl_Grd_Points_Stat
    DIM tmpl_Grd_Points_Stat as P
    tmpl_Grd_Points_Stat = a5w_load_component("Grd_Points_Statement")
    'Following code allows you to override settings in the saved component, and specify the component alias (componentName property).
    'Tip: Keep the componentName property short because this name is used in page URLs, and it will help keep the URLs short.
    'Each component on a page must have a unique alias (componentName property).
    with tmpl_Grd_Points_Stat
    DBF.filter = "Client_name = "+quote(session.current_user)
    componentName = "Grd_Points_Stat"
    end with
    '=======================================compute the HTML for the Component=======================================
    delete x_Grd_Points_Stat
    dim x_Grd_Points_Stat as p
    x_Grd_Points_Stat = a5w_run_Component(tmpl_Grd_Points_Stat)
    '=============================================================================================================
    if x_Grd_Points_Stat.RedirectURL <> "" then
    response.redirect(x_Grd_Points_Stat.redirectURL)
    end
    end if
    ?x_Grd_Points_Stat.Output.Head.JavaScript
    ?x_Grd_Points_Stat.Output.Head.CSS_Link
    %>
    <!--Alpha Five Temporary Code Start - Will be automatically removed when page is published -->
    <!--CSS for tmpl_Grd_Points_Stat -->
    <link rel="stylesheet" type="text/css" href="file:///C:/Program Files/A5V8/css/RainyDay/style.css">
    <!--Alpha Five Temporary Code End -->

    <!--Alpha Five Temporary Code Start - Will be automatically removed when page is published -->
    <!--CSS for tmpl_Grd_Menu -->
    <link rel="stylesheet" type="text/css" href="file:///C:/Program Files/A5V8/css/Perforated/components/a5navsysToolbar/style.css">
    <!--Alpha Five Temporary Code End -->

    <meta name="generator" content="Alpha Five HTML Editor Version 8 Build 1914-3142">
    <title></title>
    </head>
    <body class="RainyDayPageBODY">


    <p><table>
    <tr>
    <td valign="top"><!-- Navigation System -->
    <%a5 ?x_Grd_Menu.Output.Body.navsysTBV %>
    </td>
    <td valign="top">
    <br>
    <table>
    <tr>
    <td><%A5 ?x_Grd_Points_Stat.Output.Body.Grid_Echo %></td>
    </tr>
    <tr>
    <td><%A5 ?x_Grd_Points_Stat.Output.Body.UpdateErrors %></td>
    </tr>
    <tr>
    <td><%A5 ?x_Grd_Points_Stat.Output.Body.Search_HTML %></td>
    </tr>
    <tr>
    <td><%A5 ?x_Grd_Points_Stat.Output.Body.Grid_HTML %></td>
    </tr>
    <tr>
    <td><%A5 ?x_Grd_Points_Stat.Output.Body.DetailView_HTML %></td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    </p>
    </body></html>

  4. #4
    "Certified" Alphaholic Charles Hoens's Avatar
    Real Name
    Charles Hoens
    Join Date
    Sep 2000
    Location
    Princeton, NJ
    Posts
    1,170

    Default Re: Filter Grid by Logged in User

    Here is what I do. I hope it helps you.

    Here is the code I place on the Main page that displays my information:

    dim global vcfirstlast as c
    dim global vchildpic as c
    dim global vloginid as c
    dim global vchildid as c
    vloginid=session.__protected__userid
    session.__protected__FlagIsLoggedIn = .t.
    t=table.open("parentpass")
    t.fetch_first()
    while .not. t.fetch_eof()
    if vloginid=alltrim(t.loginid)
    vchildid=alltrim(t.childid)
    vcfirstlast=alltrim(t.cfirstlast)
    vchildpic=t.childpic
    end if
    t.fetch_next()
    end while

    In this example, I first set various global variables I want to use. I then use "vloginid" to capture the user's login information.

    ParentPass is an A5 dbf that has within it the login name. Therefore I can then search that dbf to get the information I need i.e. t.loginid or the global variable vloginid.

    On the grid component I can then set it to filter to something like childid=var->vloginid where childid is the key of the dbf you are displaying in your component.

    It took me weeks to figure this out. Hope it helps.

    Good luck,

    Charlie

Similar Threads

  1. Base Filter / User Filter - V8 vs. V7
    By Sbrowning in forum Alpha Five Version 7
    Replies: 1
    Last Post: 04-25-2008, 01:00 PM
  2. How do I determine "security group" from logged in user?
    By Fulltimer in forum Application Server Version 8
    Replies: 2
    Last Post: 01-24-2008, 09:50 PM
  3. Filter Grid by user group upon Grid Load
    By andi in forum Application Server Version 8
    Replies: 0
    Last Post: 06-13-2007, 10:30 PM
  4. Replies: 0
    Last Post: 06-13-2007, 04:53 AM
  5. Filter by logged on user
    By RickK in forum Web Application Server v7
    Replies: 1
    Last Post: 09-21-2006, 07:44 AM

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
  •