[CLOSED] grid row focus

  1. #1

    [CLOSED] grid row focus

    hi,

    i have manually move the 10th page of the grid and focus the second record of the gridpanel. but the code is not working. plz check my code.


    
    
    
    <%@ Page Language="C#" %>
    
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    
    <!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 id="Head1" runat="server">
    
    
    <title></title>
    
    
    <script runat="server"> 
    
    
    
    
    
    protected void MaskClick1(object sender, AjaxEventArgs e)
    
    
    {
    
    
    
    
    
    // page number = getIntValue((position number)/(page size))+1 - it is formula only, not code
    
    
    System.Data.DataTable dt = new System.Data.DataTable();
    
    
    dt.Columns.Add("POS_VALUE", typeof(string));
    
    
    dt.Columns.Add("POS_DESCR", typeof(string));
    
    
    System.Data.DataRow DrNew = null;
    
    
    for (int i = 0; i < 500; i++)
    
    
    {
    
    
    DrNew = dt.NewRow();
    
    
    DrNew[0] = i;
    
    
    DrNew[1] = "Test";
    
    
    dt.Rows.Add(DrNew);
    
    
    dt.AcceptChanges();
    
    
    }
    
    
    Sto4.DataSource = dt;
    
    
    Sto4.DataBind();
    
    
    
    
    
    }
    
    
     
    
    
    protected void MaskClick(object sender, AjaxEventArgs e)
    
    
    {
    
    
    //int number = Convert.ToInt32(55/25)+1 ;
    
    
    PagingToolBar2.PageIndex = 10; 
    
    
    RowSelectionModel sm = this.GrdPnl1.SelectionModel.Primary as RowSelectionModel;
    
    
    sm.SelectedRows.Add(new SelectedRow(1)); 
    
    
    sm.UpdateSelection();
    
    
    }
    
    
    
    
    
    
    
    
    </script>
    
    
    </head>
    
    
    <body>
    
    
    <form id="form1" runat="server">
    
    
    
    
    
    
    
    
    
    
    
    <ext:ScriptManager ID="ScriptManager1" runat="server" RenderStyles="File"> 
    
    
    
    
    
    </ext:ScriptManager> 
    
    
    
    
    
    <ext:Store ID="Sto4" runat="server">
    
    
    <Reader>
    
    
    <ext:JsonReader>
    
    
    <Fields> 
    
    
    <ext:RecordField Name="POS_VALUE"></ext:RecordField>
    
    
    <ext:RecordField Name="POS_DESCR"></ext:RecordField> 
    
    
    </Fields>
    
    
    </ext:JsonReader>
    
    
    </Reader>
    
    
    </ext:Store> 
    
    
    
    
    
    <ext:Button ID="Button2" runat="server" Text="Bind Record"> 
    
    
    <AjaxEvents> 
    
    
    <Click OnEvent="MaskClick1" >
    
    
    </Click> 
    
    
    </AjaxEvents> 
    
    
    </ext:Button> 
    
    
    
    
    
    
    
    
    
    
    
    <ext:Button ID="Button1" runat="server" Text="Focus row"> 
    
    
    <AjaxEvents> 
    
    
    <Click OnEvent="MaskClick"> 
    
    
    </Click> 
    
    
    </AjaxEvents> 
    
    
    </ext:Button> 
    
    
    <ext:GridPanel 
    
    
    ID="GrdPnl1" 
    
    
    runat="server"
    
    
    AutoHeight="true"
    
    
    StoreID="Sto4" 
    
    
    >
    
    
    <ColumnModel>
    
    
    <Columns>
    
    
    <ext:Column DataIndex="POS_VALUE" Width="50" Header="COLOUMN1" />
    
    
    <ext:Column DataIndex="POS_DESCR" Width="100" Header="COLOUMN2" />
    
    
    </Columns>
    
    
    </ColumnModel> 
    
    
    <SelectionModel>
    
    
    <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" />
    
    
    </SelectionModel>
    
    
    
    
    
    
    
    
    <BottomBar>
    
    
    <ext:PagingToolBar ID="PagingToolBar2" runat="server" PageSize="20" StoreID="Sto4" DisplayInfo="true" />
    
    
    </BottomBar> 
    
    
    </ext:GridPanel>
    
    
    
    
    
    
    
    
    
    
    
    
    </form>
    
    
    </body>
    
    
    </html>
  2. #2

    RE: [CLOSED] grid row focus

    Hi,

    Please see the following sample
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    <!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 id="Head1" runat="server">
        <title></title>
    
        <script runat="server"> 
    
    
            protected void MaskClick1(object sender, AjaxEventArgs e)
            {
                // page number = getIntValue((position number)/(page size))+1 - it is formula only, not code
                System.Data.DataTable dt = new System.Data.DataTable();
    
                dt.Columns.Add("POS_VALUE", typeof(string));
                dt.Columns.Add("POS_DESCR", typeof(string));
                System.Data.DataRow DrNew = null;
                for (int i = 0; i < 500; i++)
                {
                    DrNew = dt.NewRow();
                    DrNew[0] = i;
                    DrNew[1] = "Test";
                    dt.Rows.Add(DrNew);
                    dt.AcceptChanges();
                }
                Sto4.DataSource = dt;
                Sto4.DataBind();
            }
    
            protected void MaskClick(object sender, AjaxEventArgs e)
            {
                //int number = Convert.ToInt32(55/25)+1 ;
                PagingToolBar2.PageIndex = 10;
                Sto4.On("load", new JFunction("this.getSelectionModel().selectRow(1);"), "GrdPnl1", new HandlerConfig { Single = true });
            }
        </script>
        
    </head>
    <body>
        <form id="form1" runat="server">
        
            <ext:ScriptManager ID="ScriptManager1" runat="server">
            </ext:ScriptManager>
            <ext:Store ID="Sto4" runat="server">
                <Reader>
                    <ext:JsonReader>
                        <Fields>
                            <ext:RecordField Name="POS_VALUE">
                            </ext:RecordField>
                            <ext:RecordField Name="POS_DESCR">
                            </ext:RecordField>
                        </Fields>
                    </ext:JsonReader>
                </Reader>
            </ext:Store>
            <ext:Button ID="Button2" runat="server" Text="Bind Record">
                <AjaxEvents>
                    <Click OnEvent="MaskClick1">
                    </Click>
                </AjaxEvents>
            </ext:Button>
            <ext:Button ID="Button1" runat="server" Text="Focus row">
                <AjaxEvents>
                    <Click OnEvent="MaskClick">
                    </Click>
                </AjaxEvents>
            </ext:Button>
            <ext:GridPanel ID="GrdPnl1" runat="server" AutoHeight="true" StoreID="Sto4">
                <ColumnModel>
                    <Columns>
                        <ext:Column DataIndex="POS_VALUE" Width="50" Header="COLOUMN1" />
                        <ext:Column DataIndex="POS_DESCR" Width="100" Header="COLOUMN2" />
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:RowSelectionModel ID="RowSelectionModel1" runat="server" />
                </SelectionModel>
                <BottomBar>
                    <ext:PagingToolbar ID="PagingToolBar2" runat="server" PageSize="20" StoreID="Sto4"
                        DisplayInfo="true" />
                </BottomBar>
            </ext:GridPanel>
        
    
        </form>
    </body>
    </html>

Similar Threads

  1. [CLOSED] Place focus in first row of grid
    By Pablo_Azevedo in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Mar 23, 2012, 4:09 PM
  2. [CLOSED] Grid Focus
    By softmachine2011 in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Mar 05, 2012, 2:58 PM
  3. [CLOSED] Grid Focus visible
    By speedstepmem2 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 27, 2009, 3:58 PM
  4. [CLOSED] Focus removing on Grid
    By speedstepmem2 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 27, 2009, 4:49 AM
  5. [CLOSED] Focus on first row in grid?
    By Jurke in forum 1.x Legacy Premium Help
    Replies: 14
    Last Post: Dec 18, 2008, 7:12 AM

Posting Permissions