[CLOSED] PartialView to replace the contents of a div.

  1. #1

    [CLOSED] PartialView to replace the contents of a div.

    Hi,

    I originally posted this problem a few weeks ago:

    http://forums.ext.net/showthread.php...a-DirectEvents

    But the problem has come back, and I'm not sure why/how! Basically, when a row is clicked in my grid, I need to replace the contents of a Div with the results of a PartialView render. Instead of replacing the content, it's appending to the end of it.

    My trigger on the RowSelect of the grid:

         <DirectEvents>
                            <RowSelect Url="/Partial/ChannelView" CleanRequest="true">
                                <ExtraParams>
                                    <ext:Parameter Name="containerId" Value="#{ChangesChannel}.body.id" Mode="Raw" />
                                    <ext:Parameter Name="equipmentId" Value="#{ChangesGridPanel}.getSelectionModel().getSelected().data.EquipmentId" Mode="Raw" />
                                    <ext:Parameter Name="equipmentPortNum" Value="#{ChangesGridPanel}.getSelectionModel().getSelected().data.EquipmentPortNum" Mode="Raw" />
                                </ExtraParams>
                            </RowSelect>
                        </DirectEvents>
    And my controller code:

            public ActionResult ChannelView(string containerId, string equipmentId, string equipmentPortNum)
            {
                ViewData["Channel"] = _builder.BuildChannel(Convert.ToInt32(equipmentId), Convert.ToInt32(equipmentPortNum));
                PartialViewResult pr = new PartialViewResult(containerId, RenderMode.RenderTo);
                //pr.ControlToRender = "ChangesChannel";
                return pr;
            }
    I can see the result from this in firebug looks like this:
    {script:"Ext.net.append(Ext.net.getEl(\"ext-gen17\"),[\"<div id=\\\"ID_0a6a0587239842429369028bca256a88_Container\\\">\",\"<div id=\\\"ID_0a6a0587239842429369028bca256a88_Content\\\" class=\\\"x-hidden\\\">\",\"<div class=\\\"channel\\\">\",\"   \",\"  \",\"        <div class=\\\"channel-port\\\">\",\"            \",\"                <img src=\\\"/Content/Images/Port.png\\\" alt=\\\"port\\\"/>\",\"            \",\"            <p>WC1-R02</p>\",\"        </div>\",\"        \",\"            <div class=\\\"channel-cable\\\">\",\"                <div class=\\\"border Permanent\\\" \",\"                    \",\"                    ></div>\",\"                <p>WC1-R02-10</p>\",\"            </div>\",\"            \",\"        <div class=\\\"channel-port\\\">\",\"            \",\"                <img src=\\\"/Content/Images/Port.png\\\" alt=\\\"port\\\"/>\",\"            \",\"            <p></p>\",\"        </div>\",\"        \",\"</div>\",\"</div>\",\"</div>\"].join(''));Ext.net.ResourceMgr.destroyCmp(\"ID_0a6a0587239842429369028bca256a88\");new Ext.Panel({id:\"ID_0a6a0587239842429369028bca256a88\",contentEl:\"ID_0a6a0587239842429369028bca256a88_Content\",renderTo:\"ext-gen17\",border:false,header:false});"}
    How can I replace instead of appending the content?
    Last edited by Daniil; Feb 24, 2011 at 11:07 AM. Reason: [CLOSED]
  2. #2
    Hi,

    I can suggest you to just clear panel's content before loading new content, please use Before handler.
    <Click Url="/Partial/Channel" CleanRequest="true" Before="ChangesChannel.update()">
    But there is a one problem - memory leaking.

    .update() doesn't destroy panel's widgets and they leaves in the memory.

    So, it's required to destroy them manually. Well, I can suggest you to investigate the following example.
    https://examples1.ext.net/#/XRender/...UpdateContent/

    Widgets are stored in cache and removed of necessity.
  3. #3
    Thanks.

    My "partial" doesn't actually render any ExtJS objects - its a simple set of divs with no ExtJS functionality at all, so in my case I don't think memory leakage will apply, right?
  4. #4
    Yes, you are right. Sometimes I forget that we can avoid Ext.Net using:)

Similar Threads

  1. [CLOSED] PartialView in MVC4
    By UnifyEducation in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 27, 2012, 9:37 AM
  2. Replies: 0
    Last Post: May 03, 2012, 2:21 AM
  3. [CLOSED] Accessing the ID of ext component in a partialView
    By SymSure in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: May 18, 2011, 9:09 PM
  4. [CLOSED] Callback from a PartialView
    By Stefanaccio in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Oct 11, 2010, 11:39 AM
  5. [CLOSED] Add or replace item in Store
    By macap in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 22, 2010, 3:17 PM

Tags for this Thread

Posting Permissions