[CLOSED] Render property of type List<T> in GridPanel column

  1. #1

    [CLOSED] Render property of type List<T> in GridPanel column

    Is it possible to render a property of type List<T> in a GridPanel column as a comma separated list?

    For example:
    A User object contains a list of Roles ("user.Roles"). How can the Roles be rendered as "Admin, SuperUser, User" etc.?

    Can you show me the direction in how to setup the Store and the GridPanel (render or convert functions)?
    Last edited by geoffrey.mcgill; Feb 09, 2011 at 5:13 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Please see the following example. The key thing is IsComplex="true".

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!X.IsAjaxRequest)
            {
                Store store = this.GridPanel1.GetStore();
                store.DataSource = new List<object> 
                { 
                    new { 
                        Name = "user1", 
                        Roles = new List<string> { 
                                "role1", "role2", "role3" 
                        } 
                    },
                    new { 
                        Name = "user2", 
                        Roles = new List<string> { 
                                "role4", "role5", "role6" 
                        } 
                    }
                };
                store.DataBind();
            }
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true">
            <Store>
                <ext:Store runat="server">
                    <Reader>
                        <ext:JsonReader>
                            <Fields>
                                <ext:RecordField Name="Name" />
                                <ext:RecordField Name="Roles" IsComplex="true" />
                            </Fields>
                        </ext:JsonReader>
                    </Reader>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:Column Header="Name" DataIndex="Name" />
                    <ext:Column Header="Roles" DataIndex="Roles" />
                </Columns>
            </ColumnModel>
        </ext:GridPanel>
        </form>
    </body>
    </html>
    Last edited by geoffrey.mcgill; Feb 09, 2011 at 5:13 PM.

Similar Threads

  1. Replies: 1
    Last Post: Jan 02, 2012, 5:13 PM
  2. Replies: 2
    Last Post: Sep 28, 2011, 8:28 AM
  3. [CLOSED] Render gridpanel column depending on value other field store
    By CarWise in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Oct 21, 2010, 2:50 PM
  4. List Inside Column of GridPanel.
    By grmontero in forum 1.x Help
    Replies: 0
    Last Post: Sep 24, 2009, 11:12 AM
  5. [CLOSED] GridPanel Column Header render issue
    By mjessup in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Apr 01, 2009, 12:13 PM

Tags for this Thread

Posting Permissions