[CLOSED] Dynamic Columns and Fields MVC application

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Dynamic Columns and Fields MVC application

    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
    Last edited by Daniil; Feb 27, 2012 at 7:05 PM. Reason: [CLOSED]
  2. #2
    Hi,

    I can suggest the following solution.

    Example View
    <%@ 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>
    Examples Controller Action
    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;
    }
    Last edited by Daniil; Feb 27, 2012 at 7:20 PM.
  3. #3
    It seems you do not recognize the type <Model>.

    Displays this error message:



    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
    Last edited by Daniil; Feb 27, 2012 at 2:32 PM. Reason: Please use [CODE] tags
  4. #4
    Do you use Ext.NET v1, not v2?
  5. #5
    I use version 1.0
  6. #6
    Can I already use version 2.0 in my application ?
  7. #7
    Quote Originally Posted by romeu View Post
    I use version 1.0
    Please post Ext.NET v1 related technical support questions on the Premium Help 1.x forum, not on the 2.x one.
    Last edited by Daniil; Feb 27, 2012 at 7:04 PM.
  8. #8
    Quote Originally Posted by romeu View Post
    Can I already use version 2.0 in my application ?
    It would be best to start a new forum thread for this question since it's not related to the initial topic.
  9. #9
    Sorry, i creat a new post.


    Can you close this.
  10. #10
    I created another, you can close this please.

    thank you
Page 1 of 2 12 LastLast

Similar Threads

  1. [CLOSED] number fields in grid/columns
    By marco.morreale in forum 2.x Premium Help
    Replies: 6
    Last Post: May 18, 2012, 6:22 PM
  2. [CLOSED] Dynamic Columns and Fields MVC application.
    By romeu in forum 1.x Premium Help
    Replies: 1
    Last Post: Feb 27, 2012, 7:23 PM
  3. Replies: 2
    Last Post: Feb 09, 2010, 7:51 PM
  4. Dynamic fields
    By Wtower in forum 1.x Help
    Replies: 2
    Last Post: Apr 20, 2009, 6:57 PM
  5. Replies: 3
    Last Post: Feb 22, 2009, 3:18 PM

Posting Permissions