Alpha Video Training
Results 1 to 13 of 13

Thread: how do I make dropdown field read only?

  1. #1
    Member
    Real Name
    Olga
    Join Date
    Jun 2008
    Posts
    94

    Default how do I make dropdown field read only?

    Hi all,

    I have a read-only grid that has a dropdown field in it. However, user can click on this field, browse the list of values and select a different value. Of course, he is not able to save a new value, but he can get an impression that he did a change. If there is a way to specify in the grid field properties something to make this field readonly (gray), so user was not able even to see the drop down contents and pick a different value?

    Thank you for any help,
    Olga

  2. #2
    Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,827

    Default Re: how do I make dropdown field read only?

    Change the fileld type to Label.
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  3. #3
    Member
    Real Name
    Olga
    Join Date
    Jun 2008
    Posts
    94

    Default Re: how do I make dropdown field read only?

    Hi Steve,

    Thank you for your suggestion, but the reason why I'm using dropdown is to show a value from a different table using a key that is stored in the table grid is based on. So if I change it to Label a code instead of the value will be displayed...

    Actually I can make it custom control, but in this case SQL will be generated as many times, as many rows are in the grid. So I'm trying to make it work a little bit faster and use of readonly dropdown seems to me a good choice... But I don't know if it is possible...

    I don't know if that is important, but I'm using SQL Server as a backend DB.

    Thank you,
    Olga

  4. #4
    Moderator Steve Wood's Avatar
    Real Name
    Steve Wood
    Join Date
    Nov 2003
    Location
    Bay Area, California
    Posts
    8,827

    Default Re: how do I make dropdown field read only?

    Well, I think "read-only dropdownbox" would be an oxymoron, not possible. Add to that, your HTML has to re-create the entire list of related records for each row in order to show the values in the dropdown. So that itself takes some time to generate. (Look at the source of your page, each option on the dropdown will be repeated for each row.).

    I think you want a Calculated Field using a lookup() or lookupc() function to get your exact value, and display that as a Label.
    Steve Wood
    Join the ALPHA DEVELOPERS NETWORK
    There is no Cloud. It's just someone else's computer.
    Web - Mobile - Hosting - Products - Frameworks - Developer Resources
    AlphaToGo | IADN (100% Alpha Anywhere Websites)

  5. #5
    "Certified" Alphaholic NoeticCC's Avatar
    Real Name
    Andrea Gill
    Join Date
    Nov 2007
    Location
    Golcar, West Yorkshire, UK
    Posts
    2,070

    Default Re: how do I make dropdown field read only?

    Quote Originally Posted by moiola View Post
    Hi Steve,

    Thank you for your suggestion, but the reason why I'm using dropdown is to show a value from a different table using a key that is stored in the table grid is based on. So if I change it to Label a code instead of the value will be displayed...
    I use sql_lookup or lookup functions for this purpose OR just a view, that's what views are for after all.

  6. #6
    Member
    Real Name
    Olga
    Join Date
    Jun 2008
    Posts
    94

    Default Re: how do I make dropdown field read only?

    Well, I was thinking something that will give me approximately the same result as this html:

    Code:
    <select name="test" disabled>
    	<option value="1">Value 1
    	<option selected value="2">Value 2
    	<option value="3">Value 3
    </select>
    but I just don't know how to make a configuration in the grid to have the same result. I understand that html will be recreated as many times as may rows I have, but it will connect to DB only once, isn't it?

    I've never been dealing with lookup() function, it seems that it only works with dbf tables, and I have MS SQL Server at the backend...

    Thank you,
    Olga

  7. #7
    Moderator
    Real Name
    Alan Buchholz
    Join Date
    Oct 2000
    Location
    Delavan, Wisconsin
    Posts
    9,581

    Default Re: how do I make dropdown field read only?

    Quote Originally Posted by moiola View Post
    I've never been dealing with lookup() function, it seems that it only works with dbf tables, and I have MS SQL Server at the backend...
    Andrea's comment is spot on.

    You should be using a view from MS SQL.

    Or you can build your own view in WAS.

    You don't need a dropdown field. Just display the value from the view that is already translated from the code to the value that you want to display.

    The concept is similar to a one to one set in A5.

    You do need the display values in a table so they can be linked properly in the view.
    Al Buchholz
    Bookwood Systems, LTD
    Weekly QReportBuilder Webinars Thursday 1 pm CST

    Occam's Razor - KISS
    Normalize till it hurts - De-normalize till it works.
    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
    When we triage a problem it is much easier to read sample systems than to read a mind.

  8. #8
    Member
    Real Name
    Olga
    Join Date
    Jun 2008
    Posts
    94

    Default Re: how do I make dropdown field read only?

    Thank you very much, it seems to be a right approach, but I still have one concern: this grid has a detail view which is updatable. In case I base my grid on a view instead of a table, will I still be able to update it?

    Thank you,
    Olga

  9. #9
    "Certified" Alphaholic NoeticCC's Avatar
    Real Name
    Andrea Gill
    Join Date
    Nov 2007
    Location
    Golcar, West Yorkshire, UK
    Posts
    2,070

    Default Re: how do I make dropdown field read only?

    Quote Originally Posted by moiola View Post
    Thank you very much, it seems to be a right approach, but I still have one concern: this grid has a detail view which is updatable. In case I base my grid on a view instead of a table, will I still be able to update it?

    Thank you,
    Olga
    It depends on the database, some allow you to set up updatable views and others don't. To be safe, your best bet is to use SQL_Lookup() in a grid, as otherwise as far as I can tell the dropdown gets loaded for each row which can slow things down a lot too.

  10. #10
    Member
    Real Name
    Olga
    Join Date
    Jun 2008
    Posts
    94

    Default Re: how do I make dropdown field read only?

    Andrea, thank you for your help,

    I'm now using the SQL_Lookup() function. To use that, I had to set a type of my field to "Custom". And here I bumped into a problem that object data.field_name that is supposed to return a field_name value for the current grid row always returns me the value for the last row.

    Is that possible to use this function in another place? I.e. in freeform layout? I tried to use that there, but got errors...

    Thanks,
    Olga

  11. #11
    "Certified" Alphaholic NoeticCC's Avatar
    Real Name
    Andrea Gill
    Join Date
    Nov 2007
    Location
    Golcar, West Yorkshire, UK
    Posts
    2,070

    Default Re: how do I make dropdown field read only?

    Quote Originally Posted by moiola View Post
    To use that, I had to set a type of my field to "Custom". And here I bumped into a problem that object data.field_name that is supposed to return a field_name value for the current grid row always returns me the value for the last row.
    Odd... I have tried this before in a grid, and if I first define the variable, then assign it the data value from the field I want, it seems to work. I do seem to recall having problems addressing data.field_name directly though, e.g. without first populating a variable with this.

    So my code is something like:

    Code:
    Dim something as c
    Dim value as c
    value = alltrim(Data.FIELD_TO_CONVERT)
     
    something = sql_lookup( "::name::DBNAME","TABLE","FIELD='" + value + "'", "FIELD_YOU_WANT")
     
    'Write Xbasic code here that returns the HTML to be displayed by this control
    FIELD_NAME_render = something

  12. #12
    Member
    Real Name
    Olga
    Join Date
    Jun 2008
    Posts
    94

    Default Re: how do I make dropdown field read only?

    Thank you, Andrea! That worked for me!
    Why it didn't work before, because I put <%a5 %> code inside %html% %html% tags...

    Thanks again,
    Olga

  13. #13
    "Certified" Alphaholic NoeticCC's Avatar
    Real Name
    Andrea Gill
    Join Date
    Nov 2007
    Location
    Golcar, West Yorkshire, UK
    Posts
    2,070

    Default Re: how do I make dropdown field read only?

    Quote Originally Posted by moiola View Post
    Thank you, Andrea! That worked for me!
    Why it didn't work before, because I put <%a5 %> code inside %html% %html% tags...

    Thanks again,
    Olga
    Aaah... hehe yes that's happened to me before too...

Similar Threads

  1. Dropdown -> Populating Dropdown in Dropdown in Grid
    By ColinJD in forum Application Server Version 8
    Replies: 0
    Last Post: 12-10-2008, 04:08 AM
  2. How to make a dropdown in grid have list of links?
    By randbo in forum Application Server Version 9 - Web/Browser Applications
    Replies: 4
    Last Post: 12-08-2008, 03:58 PM
  3. Looking for quick& easy method to make table Read Only
    By pk9 in forum Alpha Five Version 7
    Replies: 20
    Last Post: 06-28-2006, 09:57 AM
  4. Looking for quick/easy method to make table Read Only
    By pk9 in forum Web Application Server v7
    Replies: 2
    Last Post: 06-26-2006, 03:07 PM
  5. Can't make field read only
    By Stan Mathews in forum Alpha Five Version 4
    Replies: 1
    Last Post: 05-30-2000, 09:42 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
  •