I need create dynamic Collumns in GridPanel and Fields in Store.
My application is MVC.
Can you send me one example for this, please ?
Thank's
Printable View
I need create dynamic Collumns in GridPanel and Fields in Store.
My application is MVC.
Can you send me one example for this, please ?
Thank's
Hi,
I can suggest the following solution.
Example View
Examples Controller ActionCode:<%@ 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 object[]
{
new
{
test = "test1"
},
new
{
test = "test2"
}
};
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.MVC Example</title>
<script type="text/javascript">
var onSuccess = function (grid, result) {
var store = grid.getStore();
grid.addColumn(Ext.create("Ext.grid.column.Column", Ext.decode(result.column)));
store.addField(result.field);
//test
store.loadData([{
test : "test1",
someDataIndex : "new1"
}, {
test : "test2",
someDataIndex : "new2"
}]);
};
</script>
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true">
<Store>
<ext:Store runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="test" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" Text="Test" DataIndex="test" />
</Columns>
</ColumnModel>
</ext:GridPanel>
<ext:Button runat="server" Text="Add column">
<DirectEvents>
<Click Url="/Test/AddColumn" Success="onSuccess(#{GridPanel1}, result.result);" />
</DirectEvents>
</ext:Button>
</body>
</html>
Code:public ActionResult AddColumn()
{
Column c = new Column()
{
Text = "New",
DataIndex = "someDataIndex"
};
AjaxResult r = new AjaxResult();
r.Result = new
{
column = c.ToConfig(),
field = "someDataIndex"
};
return r;
}
It seems you do not recognize the type <Model>.
Displays this error message:
Code:Server Error in '/ athenasx' Application.
-------------------------------------------------- ------------------------------
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review The Following specific parse error details and modify your source file appropriately.
Parser Error Message: Type 'Ext.Net.Store' does not have a public property named 'Model'.
Source Error:
Line 330: <STORE>
Line 331 <ext:Store runat="server" AutoLoad="false" IgnoreExtraFields="false">
Line 332: <Model>
Line 333: <ext:Model AutoDataBind="true" IDProperty="CODIGO" Root="data" TotalProperty="total">
Line 334: <FIELDS>
Source File: / athenasx / Areas / Administrative / Views / ProcuraRegistro / index.aspx Line: 332
Do you use Ext.NET v1, not v2?
I use version 1.0
Can I already use version 2.0 in my application ?
Sorry, i creat a new post.
Can you close this.
I created another, you can close this please.
thank you