[CLOSED] hide controls on radio button selection change

  1. #1

    [CLOSED] hide controls on radio button selection change

    I have a group of 4 radio buttons, and I am using change direct event to create dynamic content upon their click/selection. now, I don't know how to hide/show that dynamic content upon radio button checked/unchecked.

    Below is my code:

    controller :
    public class SearchController : Controller
        {
            // GET: AddTrainee
            public ActionResult Index()
            {
                return View();
            }
    
            public AjaxResult AddUserDropDownToSearch()
            {
                AjaxResult response = new AjaxResult();
                
                Panel pnlToSearchEmployee = MakePanel("Search by Name: ");
                ComboBox cboNames = new ComboBox();
                pnlToSearchEmployee.Add(cboNames);
                response.Script = pnlToSearchEmployee.ToScript(RenderMode.AddTo, "Container1");
                
                return response;
            }
    
            private static Panel MakePanel(string title)
            {
                Panel pnlToSearchEmployee = new Panel()
                {
                    Title = title,
                    Layout = LayoutType.HBox.ToString(),
                    MarginSpec = "10",
                    ID = "pnlToSearchEmployee",
                    MaxWidth = 1600,
                    AutoScroll = true
                };
                return pnlToSearchEmployee;
            }
        }
    View:

    @
    {
        Layout = null;
        var X = Html.X();
    }
    
    @(X.Window().ID("AddSearch").Title("Add Search").Layout(LayoutType.Fit).Height(600).Width(800).Modal(true).Hidden(true)
        .Items
        (
    
            X.Panel().Layout(LayoutType.VBox).LayoutConfig(new VBoxLayoutConfig { Align = VBoxAlign.Stretch })
        .Items
        (
            X.FormPanel().Layout(LayoutType.HBox).Border(false).MinWidth(640).BodyBorder(0).BodyStyle("padding:5px 5px 5px;").Flex(1)
            .Items
            (
                X.Panel().Flex(1).Layout(LayoutType.Anchor).Border(false).BodyBorder(0)
                .Items
                (
                           X.RadioGroup()
                                .FieldLabel("Category: ")
                                .ColumnsNumber(4)
                                .AutomaticGrouping(false)
                                .Items(
                                    X.Radio().Name("search").ID("rdFName").InputValue("0").BoxLabel("First Name")
                                        .DirectEvents(d => { d.Change.Url = Url.Action("AddUserDropDownToSearch", "Search"); }),
                                    
                                    X.Radio().Name("search").ID("rdlName").InputValue("1").BoxLabel("Last Name")
                                        .DirectEvents(d => { d.Change.Url = Url.Action("AddUserDropDownToSearch", "Search"); }),
                                    X.Radio().Name("search").ID("rdLoc").InputValue("2").BoxLabel("Location")
                                        .DirectEvents(d => { d.Change.Url = Url.Action("AddUserDropDownToSearch", "Search"); }),
                                    X.Radio().Name("search").ID("rdDep").InputValue("3").BoxLabel("Department")
                                        .DirectEvents(d => { d.Change.Url = Url.Action("AddUserDropDownToSearch", "Search"); })
                                ),
    
                                    X.Container().ID("Container1")
                           
                )
    
            )
              )
        ))
    so upon selecting first name radio button, a drop down will appear, and then if I select Last name radio button, then last name dynamic drop down should appear and first name drop down should be hidden...same with other two radio buttons as well. how to do that??

    Thanks
    Last edited by Daniil; Aug 26, 2015 at 6:18 AM. Reason: [CLOSED]
  2. #2
    Hi @sharmav1,

    Please try adding this
    X.GetCmp<Ext.Net.Container>("Container1").RemoveAll();
    to the controller action.

    The full source of the controller action would be:
    public AjaxResult AddUserDropDownToSearch()
    {
        AjaxResult response = new AjaxResult();
    
        Panel pnlToSearchEmployee = MakePanel("Search by Name: ");
        ComboBox cboNames = new ComboBox();
        pnlToSearchEmployee.Add(cboNames);
    
        X.GetCmp<Ext.Net.Container>("Container1").RemoveAll();
        response.Script = pnlToSearchEmployee.ToScript(RenderMode.AddTo, "Container1");
    
        return response;
    }

Similar Threads

  1. [CLOSED] Highlight Checked Radio Button in Radio Button Group
    By rcombis in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Aug 06, 2014, 7:26 PM
  2. Radio Button Change Event
    By zghidi in forum 1.x Help
    Replies: 1
    Last Post: Jan 31, 2011, 2:48 PM
  3. [CLOSED] [1.0] Change in radio button behavior - inputvalue
    By betamax in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 18, 2010, 4:02 PM
  4. Change Radio button label color
    By Elie.fakhry in forum 1.x Help
    Replies: 5
    Last Post: Sep 23, 2010, 10:54 PM
  5. Replies: 1
    Last Post: Apr 15, 2010, 2:29 AM

Tags for this Thread

Posting Permissions