[CLOSED] GridPanel: correct way to get the row number

  1. #1

    [CLOSED] GridPanel: correct way to get the row number

    Hi again!

    I want to know what is the right way to get through javascript, the number of row I am editing.

    Because i called a js function when select a combo, and i obtained the number of row as follows:

    var copyRow = function (combo, comboStore, col)
    {
       combo.rowEditor.row
    ..}
    
    <ext:ComboBox>    
        <Listeners>
             <Select Fn="copyRow" />                                                                                        
         </Listeners>                                                                                             
    </ext:ComboBox>
    but when i downloaded the latest version, does not work anymore.

    So, i solved it as follows:

    grid.getSelectionModel().getSelectedCell()[0]; //get cell
    It is the correct way??

    The JS is NOT an event called from grid events

    Thanks in advance!
    Last edited by Daniil; Sep 10, 2010 at 11:21 AM. Reason: [CLOSED]
  2. #2
    Hello!

    I would suggest you to handle the BeforeEdit event of GridPanel.

    Example
    <%@ 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.Store.Primary;
                store.DataSource = new object[] { 
                                             new object[] {"test1"},
                                             new object[] {"test2"},
                                             new object[] {"test3"}
                                    };
                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 Example</title>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true">
            <Store>
                <ext:Store runat="server">
                    <Reader>
                        <ext:ArrayReader>
                            <Fields>
                                <ext:RecordField Name="test" />
                            </Fields>
                        </ext:ArrayReader>
                    </Reader>
                </ext:Store>
            </Store>
            <ColumnModel runat="server">
                <Columns>
                    <ext:Column Header="Test" DataIndex="test">
                        <Editor>
                            <ext:ComboBox ID="ComboBox1" runat="server">
                                <Items>
                                    <ext:ListItem Text="new test1" Value="new test1" />
                                    <ext:ListItem Text="new test2" Value="new test2" />
                                    <ext:ListItem Text="new test3" Value="new test3" />
                                </Items>
                                <Listeners>
                                    <Select Handler="alert(this.editedRowIndex + ' row')" />
                                </Listeners>
                            </ext:ComboBox>
                        </Editor>
                    </ext:Column>
                </Columns>
            </ColumnModel>
            <Listeners>
                <BeforeEdit Handler="#{ComboBox1}.editedRowIndex = e.row" />
            </Listeners>
        </ext:GridPanel>
        </form>
    </body>
    </html>

Similar Threads

  1. Replies: 2
    Last Post: Dec 03, 2012, 11:21 AM
  2. Replies: 0
    Last Post: Aug 30, 2011, 2:48 PM
  3. Replies: 2
    Last Post: May 05, 2011, 10:16 AM
  4. FORMAT NUMBER ON A GRIDPANEL
    By marcmvc in forum 1.x Help
    Replies: 2
    Last Post: Feb 21, 2011, 9:23 AM
  5. Replies: 0
    Last Post: Dec 22, 2010, 7:33 AM

Posting Permissions