[CLOSED] Focus on first row in grid?

Page 1 of 2 12 LastLast
  1. #1

    [CLOSED] Focus on first row in grid?



    Hi
    I open a page that contains a gridpanel, I want the focus to be on the first row in this gridpanel when the user enters this page. This is to enable the users to directrly use the keys up/down to choose a record.

    How do I do this?

    /Mikael
  2. #2

    RE: [CLOSED] Focus on first row in grid?

    Hi Mikael,

    Try to add for GridPanel the following listener:


    ** * * * * *<Listeners>
    ** * * * * * * *<Render Handler="this.getSelectionModel().selectFirstRow();this.view.focusRow(0);" Delay="100" />
    ** * * * * *</Listeners>



  3. #3

    RE: [CLOSED] Focus on first row in grid?

    I added a listener to the Load event of the store to highlight the first row in the grid. *Seems to work fine except I need to do a setTimeout or else the row is selected but not visually highlighted. *If I am using a datasourceproxy, then the setTimeout is not needed. *By putting this logic in the store's load, the first row will be highlighted every time the store is reloaded. *If you want this to work only the first time the store is loaded, you can attach a listener to the grid's Render event. *

    ** *<ext:Store ID="store" runat="server">
    ** * * *<AjaxEventConfig Type="Load" ViewStateMode="Exclude">
    ** * * *</AjaxEventConfig>
    ** * * *<Reader>
    ** * * * * *<ext:JsonReader>
    ** * * * * * * *<Fields>
    ** * * * * * * * * *<ext:RecordField Name="LastName">
    ** * * * * * * * * *</ext:RecordField>
    ** * * * * * * * * *<ext:RecordField Name="FirstName">
    ** * * * * * * * * *</ext:RecordField>
    ** * * * * * * *</Fields>
    ** * * * * *</ext:JsonReader>
    ** * * *</Reader>
    ** * * *<Listeners>
    ** * * * * *<Load Handler="setTimeout('#{grid}.getSelectionModel().selectFirstRow();#{grid}.getView().focusRow(0);', 100)" /> * * * * * *
    ** * * *</Listeners>
    ** *</ext:Store>

    Edit: vladimir is just too fast for me!
  4. #4

    RE: [CLOSED] Focus on first row in grid?

    yes, the version of jchau is much better if data for grid panel loads remotelly. *Thanks jchau for your code*



  5. #5

    RE: [CLOSED] Focus on first row in grid?

    I didn't know about the delay property on listeners. *Very helpful. *Thanks vladimir.
  6. #6

    RE: [CLOSED] Focus on first row in grid?

    Hi
    Thanks guys,
    This works great, but I do want to add the listener from the codebehind. I tried this but it does not work:
    
    
    GridPanel.Listeners.Render = new Listener(this.getSelectionModel().selectFirstRow();this.view.focusRow(0);" );
    Also I dont know how to get the delay set?

    /Mikael
  7. #7

    RE: [CLOSED] Focus on first row in grid?

    Hi Mikael,

                GridPanel1.Listeners.Render.Handler = "this.getSelectionModel().selectFirstRow();this.view.focusRow(0);";
                GridPanel1.Listeners.Render.Delay = 100;

  8. #8

    RE: [CLOSED] Focus on first row in grid?

    I I get error. that says that the
    GridPanel1.Listener.Renderer is write protected?

    /Mikael
  9. #9

    RE: [CLOSED] Focus on first row in grid?

    Hi,

    yes, it is readonly therefore you must set listener properties directly, not required to create Listener object.
    Does my previous code is working for you?


  10. #10

    RE: [CLOSED] Focus on first row in grid?



    Hi
    No, thats genereting the readonly error.

    /Mikael
Page 1 of 2 12 LastLast

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 row focus
    By speedstepmem4 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: May 12, 2009, 1:18 PM
  4. [CLOSED] Grid Focus visible
    By speedstepmem2 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 27, 2009, 3:58 PM
  5. [CLOSED] Focus removing on Grid
    By speedstepmem2 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 27, 2009, 4:49 AM

Posting Permissions