[CLOSED] Dynamic grid with Grouping Summary and Editors

  1. #1

    [CLOSED] Dynamic grid with Grouping Summary and Editors

    Hi,
    I'm trying to build a grid dynamically.
    The "FundName" column should be locked...and each cell editable to the right of the locked row.
    The columns are comprised of a month date range..so users can choose 12, 24,36 etc...
    Below is a running sample, but the code commented out is where I'm having the issue, adding the editor.
    Seems like I'm not adding it right?

    If I uncomment that, I get a Javascript error:
    ,{
      dataIndex: "Jul-10",
      editor: new Ext.grid.GridEditor(Ext.apply({field:{EditorJul10_ClientInit}}, {})), <-- THIS LINE IS WHERE THE ERROR OCCURS
      header: "Jul-10",
      id: "Jul-10",
      renderer: Ext.util.Format.usMoney
    },{
      dataIndex: "Aug-10",
      editor: new Ext.grid.GridEditor(Ext.apply({field:{EditorAug10_ClientInit}}, {})),
      header: "Aug-10",
      id: "Aug-10",
      renderer: Ext.util.Format.usMoney
    },{
      dataIndex: "Sep-10",
    Markup
    
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="PortfolioHoldings.aspx.cs" Inherits="Aksia.Extranet.Sandbox.Apps.PortfolioConstruction.PortfolioHoldings" %> <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %> <!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></title>       <link href="/ClientResources/site.css" rel="stylesheet" type="text/css" /></head><body>     <form id="form1" runat="server">  <ext:ResourceManager ID="ResourceManager" runat="server">    </ext:ResourceManager>     <div style="padding: 30px5px5px5px;">          <ext:GridPanel ID="gridSubRed" runat="server" StripeRows="true" TrackMouseOver="true"  AutoExpandColumn="FundName" AutoHeight="true"            Title="Data Input" ClientIDMode="Static">             <Store>                <ext:Store runat="server"   id="storeSubRed">                <Reader>                <ext:JsonReader></ext:JsonReader>                </Reader>                </ext:Store>            </Store>            <SelectionModel>                <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" SingleSelect="true">                </ext:RowSelectionModel>            </SelectionModel>            <View>                <ext:GroupingView ID="GroupingView1" runat="server" EnableGrouping="true">                </ext:GroupingView>            </View>            <Plugins>                <ext:GroupingSummary ID="GroupingSummary1" runat="server">                </ext:GroupingSummary>                            </Plugins>            <Listeners>                       </Listeners>        </ext:GridPanel>   </div>    </form></body></html>
    Code Behind
    
    
        public partial class PortfolioHoldings : System.Web.UI.Page    {         private object[] data        {            get            {                return new object[]            {               new object[] {1,"Fund 1" ,0,0,0,0,0,0,0,0,0,0,0,0 },               new object[] { 2,"Fund 2" ,0,0,0,0,0,0,0,0,0,0,0,0 },               new object[] { 3,"Fund 3" ,0,0,0,0,0,0,0,0,0,0,0,0 },               new object[] { 4,"Fund 4" ,0,0,0,0,0,0,0,0,0,0,0,0 },               new object[] { 5,"Fund 5" ,0,0,0,0,0,0,0,0,0,0,0,0  },               new object[] { 6,"Fund 6" ,0,0,0,0,0,0,0,0,0,0,0,0 }            };            }        }         protected void Page_Load(object sender, EventArgs e)        {            DateTime endPeriod = DateTime.Now;            DateTime startPeriod = DateTime.Now.AddMonths(-12);            DateTime currDate = DateTime.MaxValue;             //create dynamic store             AddField(this.storeSubRed, new RecordField() { Type = RecordFieldType.Int, Name = "FundId" });            AddField(this.storeSubRed, new RecordField() { Type = RecordFieldType.String, Name = "FundName" });            int numberOfMonths = Aksia.Common.Utilities.Calendar.MonthDifference(startPeriod, endPeriod);            for ( var x=0; x <= numberOfMonths; x++ )            {                currDate = startPeriod.AddMonths(x);                AddField(this.storeSubRed, new RecordField() { Type = RecordFieldType.Float, Name = currDate.ToString("MMM-yy") });            }                //create grid            this.gridSubRed.ColumnModel.Columns.Clear();             Column  col = new Column();            col.ColumnID = "FundId";            col.Header = "FundId";            col.Width = Unit.Pixel(1);            col.DataIndex = "FundId";            this.gridSubRed.ColumnModel.Columns.Add(col);             col = new Column();            col.ColumnID = "FundName";            col.DataIndex = "FundName";            col.Header = "Fund";            col.Width = Unit.Pixel(150);            col.Locked = true;            col.Sortable = true;            this.gridSubRed.ColumnModel.Columns.Add(col);             GroupingSummaryColumn  gCol=null;             for ( var x=0; x <= numberOfMonths; x++ )            {                currDate = startPeriod.AddMonths(x);                gCol = new GroupingSummaryColumn();                gCol.ColumnID = currDate.ToString("MMM-yy");                gCol.Header = currDate.ToString("MMM-yy");                gCol.DataIndex = currDate.ToString("MMM-yy");                 gCol.Editable = true;               //  gCol.Editor.Add(new NumberField() { ID = "Editor" + currDate.ToString("MMMyy") });                gCol.Renderer.Format = RendererFormat.UsMoney;                this.gridSubRed.ColumnModel.Columns.Add(gCol);            }             this.gridSubRed.Reconfigure();              this.storeSubRed.DataSource = this.data;            this.storeSubRed.DataBind();            this.gridSubRed.DataBind();                     }         private void AddField(Store store, RecordField field)        {            if ( X.IsAjaxRequest )                store.AddField(field);            else                store.Reader.Reader.Fields.Add(field);        }    }
    Last edited by Daniil; Jul 11, 2011 at 9:35 AM. Reason: [CLOSED]
  2. #2
    Hi,

    Please re-format the code to allow us to copy/paste and run it.

Similar Threads

  1. Add a row to Grouping Summary grid
    By neostek in forum 1.x Help
    Replies: 8
    Last Post: Aug 07, 2012, 5:19 AM
  2. [CLOSED] Problem with dynamic editors in Grid panel (SetEditor)
    By vedagopal2004 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 08, 2011, 3:16 PM
  3. Replies: 1
    Last Post: Sep 10, 2010, 9:57 AM
  4. [CLOSED] Dynamic GridPanel with Grouping Summary and Sorting
    By bethc in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jun 22, 2010, 4:22 PM
  5. [CLOSED] Remote grouping or grouping summary for GridPanel
    By jchau in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Nov 08, 2009, 10:23 PM

Posting Permissions