[CLOSED] Problem with Combobox Select Handler

  1. #1

    [CLOSED] Problem with Combobox Select Handler

    Hi,
    In my example I have a combobox and a Button and with combox's Select.Handler I set the button's visibility.but problem is if I not set a delay for select Handler there are a java-script error so I set
    l.Select.Delay = 1;
    java-script error is resolved and the code works fine,but the problem is the button visible once and next moment disrepair.which is not looks good,if set
    l.Select.Delay = 100;
    then its understand properly.Is there any other way to this.

    EXAMPLE VIEW

    @model e.Controllers.combobox
    @{
        Layout = null;
        var X = Html.X();
    }
    
    @X.ResourceManager()
    
    @(X.ComboBoxFor(obj=>obj.selected)
    .FireSelectOnLoad(true)
    .Items
    (
    new ListItem("Yes",true),
    new ListItem("No",false)
    )
    .Listeners(l=>{
        l.Select.Delay = 50;
      l.Select.Handler=@"var v=this.getValue()
                        
                        if(Ext.isDefined(v)==true && v=='true')
                        {
                        App.btn.setVisible(true);
                        }  
                        else
                        {
                        App.btn.setVisible(false);
                        }
                        ";
    }))
    @(X.Button().ID("btn").Text("Button"))
    Example Controller

    public class cobbo_selected_changeController : Controller
        {
            //
            // GET: /cobbo_selected_change/
    
            public ActionResult Index()
            {
                combobox _combobox = new combobox();
                _combobox.selected = false;
                return View(_combobox);
            }
    
        }
    
        public class combobox
        {
            public bool selected { get; set; }
        }
    Last edited by Daniil; Nov 05, 2014 at 6:31 PM. Reason: [CLOSED]
  2. #2
    Hi @matrixwebtech,

    A JavaScript error happens, because the "App.btn" is not created yet by the time when the Select listener is executed at the first time. The Button is not created yet at all.

    I can suggest to hide the Button via its (the Button's) BeforeRender listener.

    Another approach is to set .Hidden(true) for the Button initially.
  3. #3
    Hi Daniil,thanks for reply,but may I try with 2nd approach,but not working.

    Another approach is to set .Hidden(true) for the Button initially.
    X.Button().ID("btn").Text("Button")
    .Hidden(true)
  4. #4
    You should still use Delay with that approach. Do you use?
  5. #5
    No I not use Delay for this case I need a solution without delay.because in original forms I don't know how long it will take to create ,so if I put any delay,may be the button create before this or after this.

    So Daniil ,can you please refer me any script with which I can understand the button is created and I put
    l.Select.Handler=@"var v=this.getValue()
                         
                        if(Ext.isDefined(v)==true && v=='true')
                        {
                        App.btn.setVisible(true);
                        } 
                        else
                        {
                        App.btn.setVisible(false);
                        }
                        ";
    after that.
  6. #6
    because in original forms I don't know how long it will take to create ,so if I put any delay,may be the button create before this or after this.
    Could you, please, clarify why it is a problem? I don't foresee any problems with that, everything should be OK. Have you tried or just reject the idea entirely?:)

    So Daniil ,can you please refer me any script with which I can understand the button is created and I put
    You can check it this way.
    if (App.btn) {
       alert("The Button is created.");
    } else {
        alert("The Button is not created.");
    }
    Though, I don't see how it helps in your scenario.
  7. #7
    I tried both
    I can suggest to hide the Button via its (the Button's) BeforeRender listener.

    Another approach is to set .Hidden(true) for the Button initially.
    but not working,and after that I take all componet inside a viewport and put the code in
    viewport's
    l.AfterRender.Handler
    and now its working fine.
    thanks for your help.

Similar Threads

  1. [CLOSED] select the value for combobox?
    By hdsoso in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: May 20, 2014, 10:34 AM
  2. combobox: how to select on empty?
    By danilo in forum 1.x Help
    Replies: 1
    Last Post: Jun 27, 2011, 7:50 AM
  3. Replies: 2
    Last Post: May 05, 2011, 10:16 AM
  4. Get value of combobox when select a value.
    By flaviodamaia in forum 1.x Help
    Replies: 2
    Last Post: Jul 28, 2009, 5:00 PM
  5. Select a item in a Combobox
    By eliezer in forum 1.x Help
    Replies: 1
    Last Post: Apr 16, 2009, 12:23 PM

Posting Permissions