[CLOSED] Setting a ComboBox read-only w/o affecting the Triggers

  1. #1

    [CLOSED] Setting a ComboBox read-only w/o affecting the Triggers

    Good Afternoon

    I need to set a ComboBox in a 'read-only' mode so that the user can not change the selection. But the user should be able to clear the combo by clicking a Trigger...

    Any Idea on how to Disable the Box and let the Trigger be enabled ?

    Last edited by fabricio.murta; May 05, 2016 at 10:10 PM.
  2. #2
    Hello Peter!

    I believe Editable="false" is what you want!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Right, that's it :-)
  4. #4
    But there is something that doesn't work...

    I'd like to set the Combo as not editable as soon as I've set the Value in Codebehind.

    Here's an Example :

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ComboBoxBlurCodeBehind.aspx.cs" Inherits="Ext.Net.Forum.ComboBoxBlurCodeBehind" %>
    <script runat="server">
      protected void Page_Load(object sender, EventArgs e)
        var store = cboTest.GetStore();
        store.DataSource = new object[]
          new object[] {"AL", "Alabama", "The Heart of Dixie"},
          new object[] {"AK", "Alaska", "The Land of the Midnight Sun"},
          new object[] {"AZ", "Arizona", "The Grand Canyon State"},
          new object[] {"AR", "Arkansas", "The Natural State"},
          new object[] {"CA", "California", "The Golden State"},
          new object[] {"WA", "Washington", "Green Tree State"}
        cboTest.Value = "AR";
        cboTest.Editable= false; //DOES NOT WORK !?
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <form id="form1" runat="server">
        <ext:ResourceManager runat="server"/>
        <ext:ComboBox runat="server" ID="cboTest" FieldLabel="Select a single state" DisplayField="name" Width="320" LabelWidth="130" QueryMode="Local" TypeAhead="true">
            <ext:Store runat="server" AutoDataBind="true">
                <ext:Model runat="server">
                    <ext:ModelField Name="abbr"/>
                    <ext:ModelField Name="name"/>
                    <ext:ModelField Name="slogan"/>
            <Blur Handler="if(this.getRawValue( ) !== '') this.setEditable(false);"></Blur>
            <ext:FieldTrigger Icon="Clear"/>
            <TriggerClick Handler="this.clearValue();this.setEditable(true);"/>
    The Blur seems to work, she is non editable as soon as I click in the Combo and leaf with Tab (The Combo isn't grey but it is impossible to write into the box - have no idea why the box doesn't appear in grey !?)

    What can I do the set the Box Editable(False) from Code Behind ?

    Last edited by Peter.Treier; May 04, 2016 at 2:21 PM.
  5. #5
    Sorry, found the Problem - was in a old JS Class we used :-/
  6. #6
    Okay! Glad you could make it to work!

    Just a side note about your simplified example -- that you may have left to keep the sample simple: Page_Load() is run from every postback or ajax call, so that's why you often see in Examples Explorer that the function has either (or both) tests:
    if (!X.IsAjaxRequest) {
    if (!IsPostBack)
    For example, if you had a code to display a message during load without one of those tests, it would be run at every direct method/event triggered on the page.
    Fabrício Murta
    Developer & Support Expert
  7. #7
    Thanks Fabricio for the hint, I normally do that...

Similar Threads

  1. Replies: 0
    Last Post: Feb 18, 2016, 9:46 AM
  2. Replies: 3
    Last Post: Dec 06, 2011, 7:40 AM
  3. Replies: 1
    Last Post: Dec 15, 2010, 4:07 PM
  4. Replies: 4
    Last Post: Dec 02, 2010, 2:44 PM

Posting Permissions