Multiple IDs and partial views clarification

  1. #1

    [CLOSED] Multiple IDs and partial views clarification

    Hi,

    I have a partial view, which should be rendered many times inside an index page.

    If i don't set any id, all is rendered nice.
    Then I need to set IDs, for example to buttons inside the partial view, to be able to enable/disable them dinamically.
    But If I set IDs, buttons are generated only once inside a window. When I render the partial view the second time, the button disappear from the first window and is rendered in the second. (It seems to be a correction of the old "multiple id" exception).

    I would have ids on buttons, and i would have javascript to act on controls of the same partial view/window, not different window. So I logically removed the problem of multiple ids, because I would work only from a control to others controls in the same partial view/window.

    Without explicitly set IDs, how can i have js functions working on controls?

    How can I manage to do it?
    How should I set IDmode on window and on buttons?

    @(
    
     Html.X().Window()
        .Title("WINDOW 1")
        .IDMode(???)
        .CloseAction(CloseAction.Destroy)
        .Icon(Icon.Application)
        .Height(600)
        .Width(800)
        .BodyStyle("background-color: #fff")
        .BodyPadding(5)
        .Modal(false)
        .Items(items =>
                            {
    
                                items.Add(Html.X().Button()
                                    .ID("btn1")
                                    .IDMode(???)
                                        .Text("Open Window")
                                        .Icon(Icon.Application)
                                        .Listeners(listeners =>
                                        {
                                            listeners.Click.Handler = "#{btn2}.disable();";
                                        })
                                        );
    
                                items.Add(Html.X().Button()
                                    .ID("btn2")
                                    .IDMode(???)
                                    .IDMode(IDMode.Parent)
                                        .Text("Open Window")
                                        .Icon(Icon.Application)
                                        );
                            }
            )
    
    )
    And and an Index.cshtml with a button who renders the partial view.

    @Html.X().ResourceManager()
    
        @(Html.X().Button()
            .Text("Show window")
                        .DirectEvents(de =>
                        {
                            de.Click.Url = Url.Action("RenderWindow");
                        })
         )


    Thank you.
    Last edited by millenovanta; Dec 03, 2012 at 5:39 PM. Reason: CLOSED
  2. #2
    In your particular case, you can use
    listeners.Click.Handler = "this.next().disable();";
    I suggest to investigate Ext.ComponentQuery functionality in ExtJS online API
  3. #3
    Mani thanks.
    This seems to be a great solution.

    If I use component query to inspect, for example, by the name of the button, does it work if I have the same button in different container?
    Does componentQuery filter for current container only, isn't it?

    Thanks again!

    UPDATE:

    I found the final solution, using element properties of extjs.
    My new listener on the button is:

    listeners.Click.Handler = "this.up('window').down('component[itemId=35]').disable();";
    By this way I go up until I find the window container, then i go down searching for the lement by itemId. This parameter doesn't throw any exception if not unique.

    Thank you. :)
    Last edited by millenovanta; Dec 03, 2012 at 5:39 PM. Reason: Added solution

Similar Threads

  1. [CLOSED] [MVC] Cascading multi Partial views
    By UnifyEducation in forum 2.x Legacy Premium Help
    Replies: 6
    Last Post: May 10, 2012, 2:10 PM
  2. [CLOSED] Multiple partial views on single page
    By machinableed in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: May 03, 2012, 9:06 AM
  3. [CLOSED] [Razor] using partial views
    By machinableed in forum 2.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 25, 2012, 9:40 AM
  4. Adding multiple partial views in single call
    By Tallmaris in forum 1.x Help
    Replies: 0
    Last Post: Sep 14, 2011, 1:26 PM
  5. Replies: 0
    Last Post: Oct 15, 2009, 6:07 AM

Tags for this Thread

Posting Permissions