DateField HideTrigger cannot be changed

  1. #1

    DateField HideTrigger cannot be changed



    I want to make a DateField or ComboBox readonly. This can be achieved for typing using the ReadOnly property. However these types of input still allow changing of their contents using their drop-down functionality.

    There is a property called HideTrigger where I presumed I would be able to hide the trigger button and therefore prevent the user from dropping down a list or a calendar. However using this code does not work: -

    Control.HideTrigger = false;

    Is there a method of hiding the trigger button in code-behind?
  2. #2

    RE: DateField HideTrigger cannot be changed

    Hi,

    You can use the following function


    public void SetTriggerVisible(TriggerFieldBase field, bool visible)
    {
    field.AddScript("{0}.trigger.setDisplayed({1});", field.ClientID, JSON.Serialize(visible));
    }
  3. #3

    RE: DateField HideTrigger cannot be changed



    Thanks, that works perfectly.

    The remaining field now needs to be made wider so that that it only appears that the trigger is hidden. I added a line to your script to try to make the field longer but my method didn't work - what should be the syntax?

    I added {0}.width={0}.width + 10 (see below)

    field.AddScript("{0}.trigger.setDisplayed({1}); {0}.width={0}.width + 10;", field.ClientID, JSON.Serialize(visible));

    Thanks

  4. #4

    RE: DateField HideTrigger cannot be changed

    Hi,

    Need use 'setWidth' method
  5. #5

    RE: DateField HideTrigger cannot be changed



    Thanks that works. I have just two questions.

    1. I have the field width set at 200 when there is a trigger visible. This is aligned with some text boxes. When the trigger is hidden the field is smaller by the width of the missing trigger which is why I needed to set the width so that it still aligns with the other fields. To achieve this I only need to set the width to 201. Why is this? The trigger is much wider than 1 pixel.

    2. Now that I have a combo box with a value in it for display only (i.e. read only and with trigger hidden) how do I stop the drop down window from activating and showing the one value.?

Similar Threads

  1. Combobox HideTrigger in Code Behind
    By EzaBlade in forum 1.x Help
    Replies: 4
    Last Post: Apr 19, 2012, 3:47 PM
  2. [CLOSED] Datefield has been changed from its original value
    By 78fede78 in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Oct 14, 2010, 4:53 PM
  3. Replies: 1
    Last Post: Dec 26, 2009, 7:59 AM
  4. HideTrigger - combobox
    By Kaido in forum 1.x Help
    Replies: 0
    Last Post: Mar 27, 2009, 4:49 AM
  5. [FIXED] [V0.6] ComboBox HideTrigger
    By Timothy in forum Bugs
    Replies: 6
    Last Post: Jan 22, 2009, 11:57 AM

Posting Permissions