New call-to-action
Results 1 to 6 of 6

Thread: Is there a way to make [Lookup Icon] Show/Hide by a condition?

  1. #1
    Member
    Real Name
    Tom Williams
    Join Date
    Oct 2007
    Posts
    426

    Default Is there a way to make [Lookup Icon] Show/Hide by a condition?

    I think the Lookup feature in A5 is great. It fills in my new records fast and furious. My problem is the field that shows the Lookup Icon is always active. This means a user could easily OVERWRITE existing and good data.

    I would like the Lookup Icon to only appear for a new record or when that field is blank. Is there a way to control the Lookup Icon according to this condition?

  2. #2
    "Certified" Alphaholic
    Real Name
    Lee Vasic
    Join Date
    May 2010
    Location
    Salt Lake City
    Posts
    1,226

    Default Re: Is there a way to make[ Lookup Icon] Show/Hide by a condition?

    You could try something like this in the enable expression: detailView.rowState = 'enter' It will be for the text box of the lookup not just the icon.
    and the Conditional Style to change the color or identify it that it is not enabled.

  3. #3
    Member
    Real Name
    Tom Williams
    Join Date
    Oct 2007
    Posts
    426

    Default Re: Is there a way to make [Lookup Icon] Show/Hide by a condition?

    I created a workable solution to my problem with a crude but interesting methodology. As you know, the small Icon (for Lookup) is placed to the far right of the textbox field. I thought that if I couldn't turn it off, I would "cover it up".

    What I did was to use an unused text field in my table and placed it just to the right of the textbox field with the Lookup. I then made that new field 25px wide and a relative left position of -42px. This would in reality "OVERLAP" the right-side of the previous text field. Great - first problem solved. Now I needed to create a Show/Hide condition to test if my desired field was blank or not. I added this to the "fake" field. Therefore if my "real field" had data, the "fake field" SHOWED - in effect preventing a Lookup. If the "real field" was blank due to a new record, the "fake field" was hidden and exposed the Lookup Icon.

    Works like a charm and thought I'd share. Only problem is, users may wonder what that small box was doing at the end of the "real field" so I added an on click message to the "fake field" stating that Lookup was not permitted on fields that already had data.

    BTW - this was all done on a Detail View.

  4. #4
    "Certified" Alphaholic TheSmitchell's Avatar
    Real Name
    Sarah
    Join Date
    Apr 2012
    Posts
    1,334

    Default Re: Is there a way to make [Lookup Icon] Show/Hide by a condition?

    Quote Originally Posted by Fulltimer View Post
    I created a workable solution to my problem with a crude but interesting methodology. As you know, the small Icon (for Lookup) is placed to the far right of the textbox field. I thought that if I couldn't turn it off, I would "cover it up".

    What I did was to use an unused text field in my table and placed it just to the right of the textbox field with the Lookup. I then made that new field 25px wide and a relative left position of -42px. This would in reality "OVERLAP" the right-side of the previous text field. Great - first problem solved. Now I needed to create a Show/Hide condition to test if my desired field was blank or not. I added this to the "fake" field. Therefore if my "real field" had data, the "fake field" SHOWED - in effect preventing a Lookup. If the "real field" was blank due to a new record, the "fake field" was hidden and exposed the Lookup Icon.

    Works like a charm and thought I'd share. Only problem is, users may wonder what that small box was doing at the end of the "real field" so I added an on click message to the "fake field" stating that Lookup was not permitted on fields that already had data.

    BTW - this was all done on a Detail View.
    You could also use javascript to set the style.display = 'none'. Use Firebug to figure out what the ID of the element is and then plop the javascript in the appropriate loaction. I took a quick peek at some of my lookups in a grid. They appear to be of the format "{grid.componentName}.D.V.R1.<NAME OF FIELD HERE>.CUSTOMBUTTON.0" in a detail view.

    Here's a quick example of showing/hiding:
    Code:
    // Hide the element; replace FIELD_NAME_HERE with your lookup control's field name.
    $('{grid.componentName}.D.V.R1.FIELD_NAME_HERE.CUSTOMBUTTON.0').style.display = 'none';
    Code:
    // Show the element; replace FIELD_NAME_HERE with your lookup control's field name.
    $('{grid.componentName}.D.V.R1.FIELD_NAME_HERE.CUSTOMBUTTON.0').style.display = '';
    Voila! You could figure out which Detail View client side events you need to add this code in to make this happen. Or you could put it in a function call in the client-side show hide definition for your control that has the lookup. There are lots of places you could put it, actually.

    ---
    Sarah

  5. #5
    "Certified" Alphaholic TheSmitchell's Avatar
    Real Name
    Sarah
    Join Date
    Apr 2012
    Posts
    1,334

    Default Re: Is there a way to make [Lookup Icon] Show/Hide by a condition?

    Second thought: If you really wanted to be thorough, you could modify the row html and strip out the lookup icon completely in the server-side onDetailViewRender event. This would ensure that no one could access the lookup ever because it wouldn't exist on the client side.

    UPDATE: referenced the onExistingRowRender event when onDetailViewRender is more appropriate for the situation discussed here --- hiding in a detail view.

  6. #6
    Member
    Real Name
    Tom Williams
    Join Date
    Oct 2007
    Posts
    426

    Default Re: Is there a way to make [Lookup Icon] Show/Hide by a condition?

    Quote Originally Posted by TheSmitchell View Post
    Here's a quick example of showing/hiding:
    Code:
    // Hide the element; replace FIELD_NAME_HERE with your lookup control's field name.
    $('{grid.componentName}.D.V.R1.FIELD_NAME_HERE.CUSTOMBUTTON.0').style.display = 'none';
    Code:
    // Show the element; replace FIELD_NAME_HERE with your lookup control's field name.
    $('{grid.componentName}.D.V.R1.FIELD_NAME_HERE.CUSTOMBUTTON.0').style.display = '';

    ---
    Sarah
    Sarah,

    Many thanks for your insightful suggestion to my situation. I elected to use your first 2 pieces of code and found them to work as described. I simply substituted my field names and it worked. I did not know this process was available. Others can surely benefit by using this technique. Thanks again!!!

Similar Threads

  1. Show/Hide the Delete icon (red X)
    By gaby_h in forum Application Server Version 11 - Web/Browser Applications
    Replies: 2
    Last Post: 11-15-2013, 11:03 PM
  2. client side show/hide expression to show object when row is dirty
    By Selwyn Rabins in forum Application Server Version 10 - Web/Browser Applications
    Replies: 3
    Last Post: 10-22-2012, 12:41 PM
  3. Date Picker doesn't hide properly with Show/Hide
    By Larsman in forum Application Server Version 11 - Web/Browser Applications
    Replies: 4
    Last Post: 07-15-2012, 02:21 PM
  4. How to write syntax for Date comparison condition in Show/hide expression ?
    By satyanarayana in forum Application Server Version 11 - Web/Browser Applications
    Replies: 1
    Last Post: 06-05-2012, 03:59 PM
  5. Hide Help Icon when expression is entered in show/hide property.
    By leetv in forum Application Server Version 10 - Web/Browser Applications
    Replies: 0
    Last Post: 05-31-2011, 12:26 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
  •