[CLOSED] grid ColumnModel columns Javascript

  1. #1

    [CLOSED] grid ColumnModel columns Javascript

    Hi,
    I need to enumerate all rows in columnmodel in javascript

    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Test.aspx.vb" Inherits="Test" %>
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>test moving columns</title>
        <script src="Scripts/jquery-1.6.4.js"></script>
        <script type="text/javascript">
            $(window).load(function () {
                var grid = GetExtNetObj("gridTest");
                $("#ByJS").html(grid.columns.length);
            });
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ResourceManager runat="server"  ID="ResourceMng"/>
            <ext:GridPanel ID="gridTest" runat="server" Title="Test moving" Border="true">
                <HeaderConfig runat="server">
                </HeaderConfig>
                <Store>
                    <ext:Store ID="StoreTest" runat="server" RemoteFilter="true" AutoLoad="false">
                        <Model>
                            <ext:Model ID="ModelTest" runat="server">
                                <Fields>
                                       <ext:ModelField Name="LOCK1" Type="String"></ext:ModelField>
                                       <ext:ModelField Name="LOCK2" Type="String"></ext:ModelField>
                                       <ext:ModelField Name="LOCK3" Type="String"></ext:ModelField>
                                       <ext:ModelField Name="FREE1" Type="String"></ext:ModelField>
                                       <ext:ModelField Name="FREE2" Type="String"></ext:ModelField>
                                       <ext:ModelField Name="FREE3" Type="String"></ext:ModelField>
                                    </Fields>
                            </ext:Model>
                        </Model>
                    </ext:Store>
                </Store>
                <ColumnModel ID="ColumnModelTest" runat="server">
                    <Columns>
                        <ext:Column runat="server" ID="Lock1" DataIndex="LOCK1" Width="150" Text="LOCK1" Align="Left" Locked="true" Hideable="false" Sortable="true"></ext:Column>
                        <ext:Column runat="server" ID="Lock2" DataIndex="LOCK2" Width="150" Text="LOCK2" Align="Left" Locked="true" Hideable="false" Sortable="true"></ext:Column>
                        <ext:Column runat="server" ID="Lock3" DataIndex="LOCK3" Width="150" Text="LOCK3" Align="Left" Locked="true" Hideable="false" Sortable="true"></ext:Column>
                        <ext:Column runat="server" Text="Gruppo" DataIndex="GRUPPO">
                            <Columns>
                                <ext:Column runat="server" ID="Free1" DataIndex="FREE1" Width="150" Text="FREE1" Align="Left" Sortable="true"></ext:Column>
                                <ext:Column runat="server" ID="Free2" DataIndex="FREE2" Width="150" Text="FREE2" Align="Left" Sortable="true"></ext:Column>
                                <ext:Column runat="server" ID="Free3" DataIndex="FREE3" Width="150" Text="FREE3" Align="Left" Sortable="true"></ext:Column>
                            </Columns>
                        </ext:Column>
                    </Columns>
                </ColumnModel>
            </ext:GridPanel>
            <div id="ByVB">
                <%=gridTest.ColumnModel.Columns.Count %>
            </div>
    <div id="ByJS">
    </div>
        </form>
    </body>
    </html>
    In DIV ByVB total is 4
    In DIV ByJS total is 6

    How can I access to gridTest.ColumnModel.Columns with javascript?
    Thanks in advance
    Polo
    Last edited by Daniil; Aug 20, 2014 at 12:30 PM. Reason: [CLOSED]
  2. #2
    Hi @PoloTheMonk,

    You can access column via a headerCt of the locked and normal (not locked) parts of a locking GridPanel.
    App.gridText.lockedGrid.headerCt.items.each(function(col) {
        console.log(col.text);
    });
    App.gridText.normalGrid.headerCt.items.each(function(col) {
        console.log(col.text);
    })
    Last edited by Daniil; Aug 19, 2014 at 1:29 PM.
  3. #3
    Hi @Daniil

    if I try your code I get this error

    Uncaught TypeError: Cannot read property 'normalGrid' of undefined
    or
    Uncaught TypeError: Cannot read property 'lockedGrid' of undefined
    Is there a solution?
    Thanks
    Bye
    Polo
  4. #4
    Please replace
    App.gridText
    with
    App.gridTest
  5. #5
    Well!
    Done with this

    var grid = GetExtNetObj("gridTest");
    grid.normalGrid.headerCt.items.each(function (col) {
    console.log(col.text);
    });
    Good job @Daniil
    Thanks!

Similar Threads

  1. [CLOSED] Get ColumnName from ColumnModel using javascript
    By speedstepmem4 in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Dec 17, 2013, 12:28 PM
  2. Replies: 6
    Last Post: Apr 23, 2013, 2:20 PM
  3. Replies: 6
    Last Post: Dec 19, 2012, 6:33 PM
  4. Replies: 0
    Last Post: Aug 23, 2012, 11:55 PM
  5. [CLOSED] [1.0] ColumnModel JavaScript errors
    By egodoy in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Apr 29, 2010, 11:18 AM

Tags for this Thread

Posting Permissions