Oct 30, 2013, 4:01 AM
[CLOSED] Uncaught TypeError: Cannot read property 'data' of undefined
i add a directevent in code behind.
Uncaught TypeError: Cannot read property 'data' of undefined
the whole code is
Store =
{
new Store
{
Model = {
new Model {
IDProperty = "vouchId",
Fields =
{
new ModelField("vouchId"),
new ModelField("pzzh")
}
}
},
DataSource = data1
}
}
...
grid.DirectEvents.CellClick.Event += DirectEventHandler_CellClick;
grid.DirectEvents.CellClick.ExtraParams.Add(new Ext.Net.Parameter { Name = "vouchId", Value = "this.record.data.vouchId",Mode = ParameterMode.Raw});
public void DirectEventHandler_CellClick(object sender, DirectEventArgs e)
{
var vouchId = e.ExtraParams["vouchId"];
X.Msg.Alert(vouchId,vouchId).Show();
}
error on the front :Uncaught TypeError: Cannot read property 'data' of undefined
the whole code is
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ext.Net;
using TobrosCWTAccess;
using TobrosCWTEf;
using TobrosTools;
namespace TobrosCWT.pages.cashflow
{
public partial class cashflow_data_adjust2 : System.Web.UI.Page
{
AccVouchMainService accVouchMainService = new AccVouchMainService();
AccVouchSubService accVouchSubService = new AccVouchSubService();
protected void Page_Load(object sender, EventArgs e)
{
if (!Ext.Net.X.IsAjaxRequest)
{
}
}
protected void LoadData(object sender, StoreReadDataEventArgs e)
{
int start = e.Start;
int limit = e.Limit;
int total = 0;
var l = accVouchMainService.PageDdate(start, limit, out total);
var data = l.Select(s => new { Ddate = s.ToString().Substring(0, 10) });
// var pagingList = new Paging<System.DateTime>(data, total);
e.Total = total;
s_AccVouchMain.DataSource = data;
s_AccVouchMain.DataBind();
}
[DirectMethod]
public string GetGrid2(Dictionary<string, string> parameters)
{
return "";
}
[DirectMethod]
public string GetGrid1(Dictionary<string, string> parameters)
{
string vouchId = parameters["vouchId"];
//根据vouchId查Cwzz_AccVouchSub
var accVouchSubList = accVouchSubService.GetByVouchId1(int.Parse(vouchId));
var m = new Model { IDProperty = "SerialID" };
m.Fields.Add(new ModelField { Name = "SerialID" });
m.Fields.Add(new ModelField { Name = "VouchId" });
m.Fields.Add(new ModelField { Name = "Digest" });
m.Fields.Add(new ModelField { Name = "Ccode" });
m.Fields.Add(new ModelField { Name = "Cname", Type = ModelFieldType.Object, ServerMapping = "Cwzz_AccCode.CClass" });
m.Fields.Add(new ModelField { Name = "Jfje" });
m.Fields.Add(new ModelField { Name = "Dfje" });
m.Fields.Add(new ModelField { Name = "Bill", Type = ModelFieldType.Object, ServerMapping = "Cwzz_AccVouchMain.Bill" });
m.Fields.Add(new ModelField { Name = "Checker", Type = ModelFieldType.Object, ServerMapping = "Cwzz_AccVouchMain.Checker" });
m.Fields.Add(new ModelField { Name = "Book", Type = ModelFieldType.Object, ServerMapping = "Cwzz_AccVouchMain.Book" });
m.Fields.Add(new ModelField { Name = "VouchSource", Type = ModelFieldType.Object, ServerMapping = "Cwzz_AccVouchMain.VouchSource" });
var store = new Store { DataSource = accVouchSubList };
store.Model.Add(m);
store.DataBind();
var grid = new GridPanel();
grid.ColumnModel.Add(new SummaryColumn { DataIndex = "Digest", Text = "摘要", Flex = 1, SummaryType = SummaryType.None, SummaryRenderer = { Handler = "return '合计:';" } });
grid.ColumnModel.Add(new Column { DataIndex = "Ccode", Text = "科目编码" });
grid.ColumnModel.Add(new Column { DataIndex = "Cname", Text = "科目名称" });
grid.ColumnModel.Add(new SummaryColumn { DataIndex = "Jfje", Text = "借方金额", SummaryType = SummaryType.Sum });
grid.ColumnModel.Add(new SummaryColumn { DataIndex = "Dfje", Text = "贷方金额", SummaryType = SummaryType.Sum });
grid.ColumnModel.Add(new Column { DataIndex = "Bill", Text = "制单" });
grid.ColumnModel.Add(new Column { DataIndex = "Checker", Text = "审核" });
grid.ColumnModel.Add(new Column { DataIndex = "Book", Text = "记账" });
grid.ColumnModel.Add(new Column { DataIndex = "VouchSource", Text = "凭证来源" });
grid.Store.Add(store);
var re = new RowExpander
{
Loader = new ComponentLoader
{
Mode = LoadMode.Component,
DirectMethod = "#{DirectMethods}.GetGrid2"
}
};
var s = new Ext.Net.Summary { ID = "Summary1" };
//grid.Plugins.Add(re);
grid.Features.Add(s);
grid.Listeners.ViewReady.Handler = "this.up('gridpanel').doLayout();";
return ComponentLoader.ToConfig(grid);
}
[DirectMethod]
public string GetGrid(Dictionary<string, string> parameters)
{
string date = parameters["date"];
var ll = accVouchMainService.GetByDdate(date);
var data1 = ll.Select(v => new { vouchId = v.VouchId, pzzh = v.VouchClassCode.Trim() + "-" + StringHelper.CompStr(v.VouchNo.ToString(), "0", 4) });
var grid = new GridPanel
{
Store =
{
new Store
{
Model = {
new Model {
IDProperty = "vouchId",
Fields =
{
new ModelField("vouchId"),
new ModelField("pzzh")
}
}
},
DataSource = data1
}
},
ColumnModel =
{
Columns =
{
new Column { Text = "凭证字号", DataIndex = "pzzh",Flex = 1}
}
},
Plugins =
{
new RowExpander
{
Loader = new ComponentLoader
{
Mode = LoadMode.Component,
DirectMethod = "#{DirectMethods}.GetGrid1" ,
LoadMask=
{
ShowMask = true
},
Params=
{
new Ext.Net.Parameter
{
Name = "vouchId",
Value = "this.record.data.vouchId",
Mode = ParameterMode.Raw
}
}
}
}
}
};
grid.SelectionModel.Add(new RowSelectionModel { ID = "RowSelectionModel1" });
grid.DirectEvents.CellClick.Event += DirectEventHandler_CellClick;
grid.DirectEvents.CellClick.ExtraParams.Add(new Ext.Net.Parameter { Name = "vouchId", Value = "this.record.data.vouchId",Mode = ParameterMode.Raw});
return ComponentLoader.ToConfig(grid);
}
public void DirectEventHandler_CellClick(object sender, DirectEventArgs e)
{
var vouchId = e.ExtraParams["vouchId"];
X.Msg.Alert(vouchId,vouchId).Show();
}
}
}
Last edited by Daniil; Nov 05, 2013 at 8:34 AM.
Reason: [CLOSED]