PDA

View Full Version : [CLOSED] directmethod return value to front?



tobros
Nov 06, 2013, 8:17 AM
grid.ColumnModel.Add(new SummaryColumn { DataIndex = "Jfje", Text = "借方金额", SummaryType = SummaryType.Sum, Align = Alignment.Right, Renderer = { Fn = "render_jfje" } });



[DirectMethod]
public string RenderJe(decimal s)
{
var b = businessService.JeFormat(s);
return b;
}



var render_jfje = function (v, m, record) {
var a = App.direct.RenderJe(v);
return a;
};

717571767177

the value is return to front , but in columns show object.

Daniil
Nov 06, 2013, 10:26 AM
Hi @tobros,

Please read the following thread.
http://forums.ext.net/showthread.php?16789

It is totally actual for Ext.NET v2.x as well.

tobros
Nov 07, 2013, 1:56 AM
Hi @tobros,

Please read the following thread.
http://forums.ext.net/showthread.php?16789

It is totally actual for Ext.NET v2.x as well.

change to use directevent?
how to define directevent to render the column in code behind?


grid.ColumnModel.Add(new SummaryColumn { DataIndex = "Jfje", Text = "借方金额", SummaryType = SummaryType.Sum, Align = Alignment.Right, Renderer = { Fn = "render_jfje" } });

Baidaly
Nov 07, 2013, 3:55 AM
Hello!

As it was said by Geoffrey, it's not possible, all renderers should be defined on the client-side. You can define the script on server-side but it shall be client-side script.

What is your requirements? Maybe, we can suggest you another solution.

tobros
Nov 07, 2013, 5:56 AM
Hello!

As it was said by Geoffrey, it's not possible, all renderers should be defined on the client-side. You can define the script on server-side but it shall be client-side script.

What is your requirements? Maybe, we can suggest you another solution.

I must render number to the format "xxxxx,xxx,xxx.xx" such as 123442332.72 must format to 123,442,332.72 , but the format rule is a function wroted by other in codebehind , the rule comes from database , so i want to call the function of rule in render .

Daniil
Nov 07, 2013, 6:10 AM
You can prepare the data on server when binding to the Store.

tobros
Nov 07, 2013, 8:03 AM
You can prepare the data on server when binding to the Store.

but the column is summary column ,if prepare the data on server, it can not sum the column's value.

Vladimir
Nov 07, 2013, 8:53 AM
DirectMethod is async method, you cannot get result immediately, result will be available in success handler only
Another problem, that each record will generate request to the server, if grid contains many records (or you have many users which work in parallel with the page) then your server can be easily disabled by many requests



but the column is summary column ,if prepare the data on server, it can not sum the column's value.

Try to prepare summary on the server
http://examples2.ext.net/#/GridPanel/Plugins/Remote_GroupSummary/

tobros
Nov 08, 2013, 6:02 AM
DirectMethod is async method, you cannot get result immediately, result will be available in success handler only
Another problem, that each record will generate request to the server, if grid contains many records (or you have many users which work in parallel with the page) then your server can be easily disabled by many requests


Try to prepare summary on the server
http://examples2.ext.net/#/GridPanel/Plugins/Remote_GroupSummary/

above is group summary example , could you provide me a summary example which prepare summary on the server?

Daniil
Nov 08, 2013, 6:33 AM
The RemoteRoot doen't work for a common Summary.
https://github.com/extnet/Ext.NET/issues/295

Though, there is a solution.

Example

<%@ Page Language="C#" %>

<%@ Import Namespace="System.Globalization" %>
<%@ Import Namespace="System.Collections.Generic" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void Store_ReadData(object sender, StoreReadDataEventArgs e)
{
CultureInfo ci = new CultureInfo("en-US");

Store store = this.GridPanel1.GetStore();

store.Data = new
{
data = new List<Project>
{
new Project(100, "Ext Forms: Field Anchoring", 112, "Integrate 2.0 Forms with 2.0 Layouts", 6, 150, 0, DateTime.Parse("06/24/2007", ci)),
new Project(100, "Ext Forms: Field Anchoring", 113, "Implement AnchorLayout", 4, 150, 0, DateTime.Parse("06/25/2007", ci)),
new Project(100, "Ext Forms: Field Anchoring", 114, "Add support for multiple types of anchors", 4, 150, 0, DateTime.Parse("06/27/2007", ci)),
new Project(100, "Ext Forms: Field Anchoring", 115, "Testing and debugging", 8, 0, 0, DateTime.Parse("06/29/2007", ci)),
new Project(101, "Ext Grid: Single-level Grouping", 101, "Add required rendering \"hooks\" to GridView", 6, 100, 0, DateTime.Parse("07/01/2007", ci)),
new Project(101, "Ext Grid: Single-level Grouping", 102, "Extend GridView and override rendering functions", 6, 100, 0, DateTime.Parse("07/03/2007", ci)),
new Project(101, "Ext Grid: Single-level Grouping", 103, "Extend Store with grouping functionality", 4, 100, 0, DateTime.Parse("07/04/2007", ci)),
new Project(101, "Ext Grid: Single-level Grouping", 121, "Default CSS Styling", 2, 100, 0, DateTime.Parse("07/05/2007", ci)),
new Project(101, "Ext Grid: Single-level Grouping", 104, "Testing and debugging", 6, 100, 0, DateTime.Parse("07/06/2007", ci)),
new Project(102, "Ext Grid: Summary Rows", 105, "Ext Grid plugin integration", 4, 125, 0, DateTime.Parse("07/01/2007", ci)),
new Project(102, "Ext Grid: Summary Rows", 106, "Summary creation during rendering phase", 4, 125, 0, DateTime.Parse("07/02/2007", ci)),
new Project(102, "Ext Grid: Summary Rows", 107, "Dynamic summary updates in editor grids", 6, 125, 0, DateTime.Parse("07/05/2007", ci)),
},

summaryData = new
{
Description = 12,
Due = DateTime.Parse("07/06/2007", ci),
Estimate = 60,
Rate = 110.42,
Cost = 6250
}
};
}

public class Project
{
public Project(int projectId, string name, int taskId, string description, int estimate, double rate, double cost, DateTime due)
{
this.ProjectID = projectId;
this.Name = name;
this.TaskID = taskId;
this.Description = description;
this.Estimate = estimate;
this.Rate = rate;
this.Due = due;
}

public int ProjectID { get; set; }
public string Name { get; set; }
public int TaskID { get; set; }
public string Description { get; set; }
public int Estimate { get; set; }
public double Rate { get; set; }
public double Cost { get; set; }
public DateTime Due { get; set; }
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Summary Plugin - Ext.NET Examples</title>

<link href="/resources/css/examples.css" rel="stylesheet" />

<style>
.x-grid-body .x-grid-cell-Cost {
background-color: #f1f2f4;
}

.x-grid-row-summary .x-grid-cell-Cost .x-grid-cell-inner {
background-color: #e1e2e4;
}

.task .x-grid-cell-inner {
padding-left: 15px;
}

.x-grid-row-summary .x-grid-cell-inner {
font-weight: bold;
font-size: 11px;
background-color: #f1f2f4;
}
</style>

<script>
Ext.grid.feature.Summary.override({
createSummaryRecord: function(view) {
var columns = view.headerCt.getVisibleGridColumns(),
info = {
records: view.store.getRange()
},
colCount = columns.length, i, column,
summaryRecord = this.summaryRecord || (this.summaryRecord = new view.store.model(null, view.id + '-summary-record'));

// Set the summary field values
summaryRecord.beginEdit();

if (this.remoteRoot) {
if (view.store.proxy.reader.rawData) {
summaryRecord.set(view.store.proxy.reader.rawData. data[this.remoteRoot]); // hardcoded "summaryData"
}
} else {
for (i = 0; i < colCount; i++) {
column = columns[i];

// In summary records, if there's no dataIndex, then the value in regular rows must come from a renderer.
// We set the data value in using the column ID.
if (!column.dataIndex) {
column.dataIndex = column.id;
}

summaryRecord.set(column.dataIndex, this.getSummary(view.store, column.summaryType, column.dataIndex, info));
}
}

summaryRecord.endEdit(true);
// It's not dirty
summaryRecord.commit(true);
summaryRecord.isSummary = true;

return summaryRecord;
}
});

var totalCost = function (records) {
var i = 0,
length = records.length,
total = 0,
record;

for (; i < length; ++i) {
record = records[i];
total += record.get('Estimate') * record.get('Rate');
}

return total;
};
</script>

</head>
<body>
<form runat="server">
<h1>Summary Plugin</h1>

<ext:ResourceManager runat="server" />

<ext:GridPanel
ID="GridPanel1"
runat="server"
Title="Sponsored Projects"
Icon="ApplicationViewColumns"
Frame="true"
Collapsible="true"
Width="800"
Height="450">
<Store>
<ext:Store runat="server" OnReadData="Store_ReadData">
<Sorters>
<ext:DataSorter Property="Due" Direction="ASC" />
</Sorters>
<Model>
<ext:Model runat="server" IDProperty="TaskID">
<Fields>
<ext:ModelField Name="ProjectID" />
<ext:ModelField Name="Name" />
<ext:ModelField Name="TaskID" />
<ext:ModelField Name="Description" />
<ext:ModelField Name="Estimate" Type="Int" />
<ext:ModelField Name="Rate" Type="Float" />
<ext:ModelField Name="Cost" Type="Float" />
<ext:ModelField Name="Due" Type="Date" />
</Fields>
</ext:Model>
</Model>
<Proxy>
<ext:PageProxy>
<Reader>
<ext:JsonReader Root="data.data" />
</Reader>
</ext:PageProxy>
</Proxy>
</ext:Store>
</Store>
<Plugins>
<ext:CellEditing runat="server" ClicksToEdit="1" />
</Plugins>
<ColumnModel runat="server">
<Columns>
<ext:SummaryColumn
runat="server"
TdCls="task"
Text="Task"
Sortable="true"
DataIndex="Description"
Hideable="false"
SummaryType="Count"
Flex="1">
<SummaryRenderer Handler="return ((value === 0 || value > 1) ? '(' + value +' Tasks)' : '(1 Task)');" />
</ext:SummaryColumn>

<ext:SummaryColumn runat="server" Text="Project" DataIndex="Name" Flex="1">
<SummaryRenderer Handler="return '&nbsp;';" />
</ext:SummaryColumn>

<ext:SummaryColumn
runat="server"
Width="85"
Text="Due Date"
Sortable="true"
DataIndex="Due"
SummaryType="Max">
<Renderer Format="Date" FormatArgs="'m/d/Y'" />
<SummaryRenderer Fn="Ext.util.Format.dateRenderer('m/d/Y')" />
<Editor>
<ext:DateField runat="server" Format="MM/dd/yyyy" />
</Editor>
</ext:SummaryColumn>

<ext:SummaryColumn
runat="server"
Width="75"
Text="Estimate"
Sortable="true"
DataIndex="Estimate"
SummaryType="Sum">
<Renderer Handler="return value +' hours';" />
<SummaryRenderer Handler="return value +' hours';" />
<Editor>
<ext:NumberField runat="server" AllowBlank="false" AllowNegative="false" StyleSpec="text-align:left" />
</Editor>
</ext:SummaryColumn>

<ext:SummaryColumn
runat="server"
Width="75"
Text="Rate"
Sortable="true"
DataIndex="Rate"
SummaryType="Average">
<Renderer Format="UsMoney" />
<SummaryRenderer Fn="Ext.util.Format.usMoney" />
<Editor>
<ext:NumberField runat="server" AllowBlank="false" AllowNegative="false" StyleSpec="text-align:left" />
</Editor>
</ext:SummaryColumn>

<ext:SummaryColumn
runat="server"
Width="75"
ID="Cost"
Text="Cost"
Sortable="false"
Groupable="false"
DataIndex="Cost"
CustomSummaryType="totalCost">
<Renderer Handler="return Ext.util.Format.usMoney(record.data.Estimate * record.data.Rate);" />
<SummaryRenderer Fn="Ext.util.Format.usMoney" />
</ext:SummaryColumn>
</Columns>
</ColumnModel>
<Features>
<ext:Summary ID="Summary1" runat="server">
<CustomConfig>
<ext:ConfigItem Name="remoteRoot" Value="summaryData" Mode="Value" />
</CustomConfig>
</ext:Summary>
</Features>
<TopBar>
<ext:Toolbar runat="server">
<Items>
<ext:Button runat="server" Text="Toggle" ToolTip="Toggle the visibility of summary row">
<Listeners>
<Click Handler="#{Summary1}.toggleSummaryRow(!#{Summary1}.showSumm aryRow);#{Summary1}.view.refresh();" />
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
</ext:GridPanel>
</form>
</body>
</html>

tobros
Nov 08, 2013, 9:50 AM

Daniil
Nov 08, 2013, 11:34 AM
I don't think you should call the DataBind in your case.

If you use a PageProxy, you should bind the data using that Proxy, but you are doing that:

Data = new { data = accVouchSubList, summaryData = new { Jfje = jfjesum, Dfje = dfjesum } }

It is confusing.

Do you really need to use a PageProxy?

tobros
Nov 11, 2013, 1:55 AM
I don't think you should call the DataBind in your case.

If you use a PageProxy, you should bind the data using that Proxy, but you are doing that:

Data = new { data = accVouchSubList, summaryData = new { Jfje = jfjesum, Dfje = dfjesum } }

It is confusing.

Do you really need to use a PageProxy?

i use proxy,because it can define "Root", what's the use of proxy? it can paging?if i want to page on server, i must use proxy? what's the different with datasource?

now , in my case , the data is not too much,there is no need to page , so i use store's data propery.
but i remove the proxy, how to define "Root" to read the data in the store, and i remove the proxy,


// var pp = new PageProxy();
// pp.Reader.Add(new JsonReader { Root = "data.data" });
// store.Proxy.Add(pp);

the error still exists

Daniil
Nov 11, 2013, 5:39 AM
A Proxy is a layer between the Store and the data to read and save it.

It doesn't look that you need a Proxy in that case.

A JsonReader can be defined for a Store itself. Please try.

tobros
Nov 11, 2013, 5:57 AM
A Proxy is a layer between the Store and the data to read and save it.

It doesn't look that you need a Proxy in that case.

A JsonReader can be defined for a Store itself. Please try.

please CHECK what's wrong with my code , is it the reason dot define jsonreader?
throw stackoverflowexception when in jsonConver.serialize() function

Daniil
Nov 11, 2013, 6:02 AM
I have no idea about the latest version of your code.

Did you eliminate it?

I don't think you should call the DataBind in your case.

Did you remove the PageProxy?

Did you define a JsonReader for the Store?

tobros
Nov 11, 2013, 8:06 AM
I have no idea about the latest version of your code.

Did you eliminate it?


Did you remove the PageProxy?

Did you define a JsonReader for the Store?

i remove the pageproxy and add jsonreader for the store.my latest code is


[DirectMethod]
public string GetGrid1(Dictionary<string, string> parameters)
{
string vouchId = parameters["vouchId"];
//根据vouchId查Cwzz_AccVouchSub
var accVouchSubList = accVouchSubService.GetByVouchId1(int.Parse(vouchId ));
decimal? dfjesum = 0;
decimal? jfjesum = 0;
foreach (var cwzzAccVouchSub in accVouchSubList)
{
dfjesum += cwzzAccVouchSub.Dfje;
jfjesum += cwzzAccVouchSub.Jfje;
}
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 };
var store = new Store
{
Data = new { data = accVouchSubList, summaryData = new { Jfje = jfjesum, Dfje = dfjesum } }
};
store.Model.Add(m);
// var pp = new PageProxy();
// pp.Reader.Add(new JsonReader { Root = "data.data" });
// store.Proxy.Add(pp);
//store.DataBind();
store.Reader.Add(new JsonReader{Root = "data.data"});
var grid = new GridPanel();
grid.Store.Add(store);
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 = "科目名称" });
var c = new SummaryColumn
{
DataIndex = "Jfje",
Text = "借方金额",
// SummaryType = SummaryType.Sum,
Align = Alignment.Right,
// Renderer = { Fn = "render_jfje" }
};
// c.DirectEvents.Render.Event += C_DirectEventHandler;
grid.ColumnModel.Add(c);
var c1 = new SummaryColumn
{
DataIndex = "Dfje",
Text = "贷方金额",
// SummaryType = SummaryType.Sum,
Align = Alignment.Right,
// Renderer = { Fn = "render_dfje" }
};
grid.ColumnModel.Add(c1);
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 = "凭证来源" });

var s = new Ext.Net.Summary { ID = "Summary1" };
s.CustomConfig.Add(new ConfigItem { Name = "remoteRoot", Value = "summaryData", Mode = ParameterMode.Raw });

grid.Features.Add(s);
grid.Listeners.ViewReady.Handler = "this.up('gridpanel').doLayout();";
return ComponentLoader.ToConfig(grid);

}

Daniil
Nov 11, 2013, 4:06 PM
Probably, the data could not be serialized because of recursion.

Unlike DataSource a Store's Data is serialized as it is. It doesn't use a Model for serialization. For example, ServerMapping is not used.

Yes, it all is not going to work well for you.

Let's return back to this for now:

I must render number to the format "xxxxx,xxx,xxx.xx" such as 123442332.72 must format to 123,442,332.72 , but the format rule is a function wroted by other in codebehind , the rule comes from database , so i want to call the function of rule in render .

What kind of "the rule comes from database" are there? How frequently does they change? Could you explain, please? Maybe, we could come with something else.

tobros
Nov 12, 2013, 1:29 AM
Probably, the data could not be serialized because of recursion.

Unlike DataSource a Store's Data is serialized as it is. It doesn't use a Model for serialization. For example, ServerMapping is not used.

Yes, it all is not going to work well for you.

Let's return back to this for now:


What kind of "the rule comes from database" are there? How frequently does they change? Could you explain, please? Maybe, we could come with something else.

the function which convert decimal to the format such as conver 2124323.23 to "2,124,323.23"


public string JeFormat(decimal je)
{
try
{
if (HttpContext.Current.Request.Cookies["cwjexsws"] != null && HttpContext.Current.Request.Cookies["cwjexsws"].ToString() != "")
{
return String.Format("{0:N" + HttpContext.Current.Request.Cookies["cwjexsws"].ToString() + "}", je);
}
else
{
Gy_AccInformation acc = accInfoServ.get("Cwzz", "cwjexsws"); //which comes from database we do not care
return String.Format("{0:N" + acc.ItemValue.Trim() + "}", je);
}
}
catch
{
return String.Format("{0:N}", je);
}
}

Baidaly
Nov 12, 2013, 3:17 AM
Hello!

I'm not quite sure about it but did you try to call this formating function with your Data?



var store = new Store
{
Data = new { data = accVouchSubList, summaryData = new { Jfje = JeFormat(jfjesum), Dfje = dfjesum } }
};

Daniil
Nov 13, 2013, 11:34 AM
Hello!

I'm not quite sure about it but did you try to call this formating function with your Data?



var store = new Store
{
Data = new { data = accVouchSubList, summaryData = new { Jfje = JeFormat(jfjesum), Dfje = dfjesum } }
};


I am afraid it might cause a StackOverflow exception again.


the function which convert decimal to the format such as conver 2124323.23 to "2,124,323.23"


public string JeFormat(decimal je)
{
try
{
if (HttpContext.Current.Request.Cookies["cwjexsws"] != null && HttpContext.Current.Request.Cookies["cwjexsws"].ToString() != "")
{
return String.Format("{0:N" + HttpContext.Current.Request.Cookies["cwjexsws"].ToString() + "}", je);
}
else
{
Gy_AccInformation acc = accInfoServ.get("Cwzz", "cwjexsws"); //which comes from database we do not care
return String.Format("{0:N" + acc.ItemValue.Trim() + "}", je);
}
}
catch
{
return String.Format("{0:N}", je);
}
}


Ok. I would recommend you to find a way to replicate it on client. Maybe, you could read a rule from a database and render it to client, then use in a Renderer.

If no way, here is an example how to bind the data through a Store's DataSource and bind a summary data from a Store's CustomConfig. But in this case you will have to re-calculate the summary data manually when needed. For example, when a user edits a cell. This functionality is not presented in the example.

Example

<%@ Page Language="C#" %>

<%@ Import Namespace="System.Globalization" %>
<%@ Import Namespace="System.Collections.Generic" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
CultureInfo ci = new CultureInfo("en-US");

Store store = this.GridPanel1.GetStore();

store.DataSource = new List<Project>()
{
new Project(100, "Ext Forms: Field Anchoring", 112, "Integrate 2.0 Forms with 2.0 Layouts", 6, 150, 0, DateTime.Parse("06/24/2007", ci)),
new Project(100, "Ext Forms: Field Anchoring", 113, "Implement AnchorLayout", 4, 150, 0, DateTime.Parse("06/25/2007", ci)),
new Project(100, "Ext Forms: Field Anchoring", 114, "Add support for multiple types of anchors", 4, 150, 0, DateTime.Parse("06/27/2007", ci)),
new Project(100, "Ext Forms: Field Anchoring", 115, "Testing and debugging", 8, 0, 0, DateTime.Parse("06/29/2007", ci)),
new Project(101, "Ext Grid: Single-level Grouping", 101, "Add required rendering \"hooks\" to GridView", 6, 100, 0, DateTime.Parse("07/01/2007", ci)),
new Project(101, "Ext Grid: Single-level Grouping", 102, "Extend GridView and override rendering functions", 6, 100, 0, DateTime.Parse("07/03/2007", ci)),
new Project(101, "Ext Grid: Single-level Grouping", 103, "Extend Store with grouping functionality", 4, 100, 0, DateTime.Parse("07/04/2007", ci)),
new Project(101, "Ext Grid: Single-level Grouping", 121, "Default CSS Styling", 2, 100, 0, DateTime.Parse("07/05/2007", ci)),
new Project(101, "Ext Grid: Single-level Grouping", 104, "Testing and debugging", 6, 100, 0, DateTime.Parse("07/06/2007", ci)),
new Project(102, "Ext Grid: Summary Rows", 105, "Ext Grid plugin integration", 4, 125, 0, DateTime.Parse("07/01/2007", ci)),
new Project(102, "Ext Grid: Summary Rows", 106, "Summary creation during rendering phase", 4, 125, 0, DateTime.Parse("07/02/2007", ci)),
new Project(102, "Ext Grid: Summary Rows", 107, "Dynamic summary updates in editor grids", 6, 125, 0, DateTime.Parse("07/05/2007", ci))
};

var summaryData = new
{
Description = 12,
Due = DateTime.Parse("07/06/2007", ci),
Estimate = 60,
Rate = 110.42,
Cost = 6250
};

store.CustomConfig.Add(new ConfigItem()
{
Name = "summaryRecord",
Value = JSON.Serialize(summaryData),
Mode = ParameterMode.Raw

});
}

public class Project
{
public Project(int projectId, string name, int taskId, string description, int estimate, double rate, double cost, DateTime due)
{
this.ProjectID = projectId;
this.Name = name;
this.TaskID = taskId;
this.Description = description;
this.Estimate = estimate;
this.Rate = rate;
this.Due = due;
}

public int ProjectID { get; set; }
public string Name { get; set; }
public int TaskID { get; set; }
public string Description { get; set; }
public int Estimate { get; set; }
public double Rate { get; set; }
public double Cost { get; set; }
public DateTime Due { get; set; }
}
</script>

<!DOCTYPE html>

<html>
<head runat="server">
<title>Summary Plugin - Ext.NET Examples</title>

<link href="/resources/css/examples.css" rel="stylesheet" />

<style>
.x-grid-body .x-grid-cell-Cost {
background-color: #f1f2f4;
}

.x-grid-row-summary .x-grid-cell-Cost .x-grid-cell-inner {
background-color: #e1e2e4;
}

.task .x-grid-cell-inner {
padding-left: 15px;
}

.x-grid-row-summary .x-grid-cell-inner {
font-weight: bold;
font-size: 11px;
background-color: #f1f2f4;
}
</style>

<script>
Ext.grid.feature.Summary.override({
createSummaryRecord: function(view) {
var columns = view.headerCt.getVisibleGridColumns(),
info = {
records: view.store.getRange()
},
colCount = columns.length, i, column,
summaryRecord = this.summaryRecord || (this.summaryRecord = new view.store.model(null, view.id + '-summary-record'));

// Set the summary field values
summaryRecord.beginEdit();

if (view.store.summaryRecord) {
//summaryRecord.set(view.store.proxy.reader.rawData. data[this.remoteRoot]); // hardcoded "summaryData"
summaryRecord.set(view.store.summaryRecord);
} else {
for (i = 0; i < colCount; i++) {
column = columns[i];

// In summary records, if there's no dataIndex, then the value in regular rows must come from a renderer.
// We set the data value in using the column ID.
if (!column.dataIndex) {
column.dataIndex = column.id;
}

summaryRecord.set(column.dataIndex, this.getSummary(view.store, column.summaryType, column.dataIndex, info));
}
}

summaryRecord.endEdit(true);
// It's not dirty
summaryRecord.commit(true);
summaryRecord.isSummary = true;

return summaryRecord;
}
});

var totalCost = function (records) {
var i = 0,
length = records.length,
total = 0,
record;

for (; i < length; ++i) {
record = records[i];
total += record.get('Estimate') * record.get('Rate');
}

return total;
};
</script>

</head>
<body>
<form runat="server">
<h1>Summary Plugin</h1>

<ext:ResourceManager runat="server" />

<ext:GridPanel
ID="GridPanel1"
runat="server"
Title="Sponsored Projects"
Icon="ApplicationViewColumns"
Frame="true"
Collapsible="true"
Width="800"
Height="450">
<Store>
<ext:Store runat="server">
<Sorters>
<ext:DataSorter Property="Due" Direction="ASC" />
</Sorters>
<Model>
<ext:Model runat="server" IDProperty="TaskID">
<Fields>
<ext:ModelField Name="ProjectID" />
<ext:ModelField Name="Name" />
<ext:ModelField Name="TaskID" />
<ext:ModelField Name="Description" />
<ext:ModelField Name="Estimate" Type="Int" />
<ext:ModelField Name="Rate" Type="Float" />
<ext:ModelField Name="Cost" Type="Float" />
<ext:ModelField Name="Due" Type="Date" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<Plugins>
<ext:CellEditing runat="server" ClicksToEdit="1" />
</Plugins>
<ColumnModel runat="server">
<Columns>
<ext:SummaryColumn
runat="server"
TdCls="task"
Text="Task"
Sortable="true"
DataIndex="Description"
Hideable="false"
Flex="1">
<SummaryRenderer Handler="return ((value === 0 || value > 1) ? '(' + value +' Tasks)' : '(1 Task)');" />
</ext:SummaryColumn>

<ext:SummaryColumn runat="server" Text="Project" DataIndex="Name" Flex="1">
<SummaryRenderer Handler="return '&nbsp;';" />
</ext:SummaryColumn>

<ext:SummaryColumn
runat="server"
Width="85"
Text="Due Date"
Sortable="true"
DataIndex="Due">
<Renderer Format="Date" FormatArgs="'m/d/Y'" />
<SummaryRenderer Fn="Ext.util.Format.dateRenderer('m/d/Y')" />
<Editor>
<ext:DateField runat="server" Format="MM/dd/yyyy" />
</Editor>
</ext:SummaryColumn>

<ext:SummaryColumn
runat="server"
Width="75"
Text="Estimate"
Sortable="true"
DataIndex="Estimate">
<Renderer Handler="return value +' hours';" />
<SummaryRenderer Handler="return value +' hours';" />
<Editor>
<ext:NumberField
runat="server"
AllowBlank="false"
AllowNegative="false"
StyleSpec="text-align:left" />
</Editor>
</ext:SummaryColumn>

<ext:SummaryColumn
runat="server"
Width="75"
Text="Rate"
Sortable="true"
DataIndex="Rate">
<Renderer Format="UsMoney" />
<SummaryRenderer Fn="Ext.util.Format.usMoney" />
<Editor>
<ext:NumberField
runat="server"
AllowBlank="false"
AllowNegative="false"
StyleSpec="text-align:left" />
</Editor>
</ext:SummaryColumn>

<ext:SummaryColumn
runat="server"
Width="75"
ID="Cost"
Text="Cost"
Sortable="false"
Groupable="false"
DataIndex="Cost">
<Renderer Handler="return Ext.util.Format.usMoney(record.data.Estimate * record.data.Rate);" />
<SummaryRenderer Fn="Ext.util.Format.usMoney" />
</ext:SummaryColumn>
</Columns>
</ColumnModel>
<Features>
<ext:Summary ID="Summary1" runat="server" />
</Features>
<TopBar>
<ext:Toolbar runat="server">
<Items>
<ext:Button runat="server" Text="Toggle" ToolTip="Toggle the visibility of summary row">
<Listeners>
<Click Handler="#{Summary1}.toggleSummaryRow(!#{Summary1}.showSumm aryRow);#{Summary1}.view.refresh();" />
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
</ext:GridPanel>
</form>
</body>
</html>