[CLOSED] Dataview Templates and server-side code integration

  1. #1

    [CLOSED] Dataview Templates and server-side code integration

    Integrating server-side variables into a template is a huge pain. Is there a better way to do this? I've tried a million different things and each one has it's own issues.

    In this implementation, {name} doesn't show up in the new template. Nor does anything else in the store.

    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            dvMemberIconView.Template.Html = @"<tpl for"".""><p>{name}</p>
                                                <tpl if=""'" + Page.User.Identity.IsAuthenticated.ToString() + @"' == 'True'"">
                                                    <a href=""/User/Profiles"" >{#}. edit profile</a>
                                                 </tpl>";
           
        }
    </script>
    <ext:Store runat="server" ID="memberStore">
        <Proxy>
            <ext:HttpProxy Method="POST" Url="/Group/GetAllMembers/" />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="UserId" Root="data" TotalProperty="total">
                <Fields>
                    <ext:RecordField Name="UserId" />
                    <ext:RecordField Name="name" />
                    <ext:RecordField Name="path" />
                    <ext:RecordField Name="profile_name" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    
    <ext:Panel 
                runat="server" 
                ID="ImagePanel" 
                Layout="Fit" >
                <Items>
                    <ext:DataView ID="dvMemberIconView" 
                        runat="server"
                        StoreID="memberStore"
                        AutoHeight="true"
                        OverClass="x-view-over"
                        ItemSelector="div.thumb-wrap"
                        EmptyText="No Members">
                        <Template ID="TemplateMember" runat="server">
                            <Html>
                                 this will be replaced
                    </Html>
                        </Template>                                    
                    </ext:DataView>
                </Items>
            </ext:Panel>
    Last edited by Daniil; Apr 09, 2011 at 12:52 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Here is the example with dynamic XTemplate which works fine, please investigate.
    https://examples1.ext.net/#/Miscella...amic_Template/
  3. #3
    That's where I started. I don't want to change the data as I'm using the store. I just want to change the template. Can you please explain how to do it with a store.
  4. #4
    Hi,

    I am not sure why do you need to built in server side variables to a template.
    Just use string builder and build required template
    StringBuilder sb = new StringBuilder();
    sb.Append(@"<tpl for"".""><p>{name}</p>");
    if(Page.User.Identity.IsAuthenticated)
    {
       sb.Append(@"<a href=""/User/Profiles"" >{#}. edit profile</a>");
    }
    sb.Append("</tpl>");
    dvMemberIconView.Template.Html = sb.ToString();

Similar Threads

  1. I need this code in Server Side
    By walle in forum 1.x Help
    Replies: 1
    Last Post: Jul 20, 2011, 6:58 PM
  2. Replies: 0
    Last Post: Jun 13, 2011, 6:29 AM
  3. css from server-side code
    By unaltro2 in forum 1.x Help
    Replies: 3
    Last Post: Jan 11, 2011, 7:02 PM
  4. Javascript to server side code
    By Birgit in forum 1.x Help
    Replies: 0
    Last Post: Sep 24, 2010, 7:56 AM
  5. [CLOSED] How to set DataView template from the server side?
    By jmcantrell in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Sep 01, 2010, 6:08 PM

Posting Permissions