How to get Index of selected row?

  1. #1

    How to get Index of selected row?

    Dear All,

    I am very new into ext.net so please excuse my knowledge in it.
    I have a grid and i want to insert a new row in the middle of the 2 rows.
    For this i have written Javascript as

    grid.stopEditing();
      var s = grid.getSelectionModel().getSelections()[0];
      grid.insertRecord(s);
      grid.getView().refresh();
      grid.getSelectionModel().selectRow(s);
      grid.startEditing(s,1);
    the variable 's' is a object of selected row. Can anyone tell me how do i get rowIndex of currently selected row and new inserted row both?
    Is the code that i have written correct?

    Regards,
    Huzefa
  2. #2
    Try this
    grid.stopEditing();
      var record = grid.getSelectionModel().getSelected(),
          index = grid.store.indexOf(record),
          newRecord = grid.insertRecord(index, record.data);
    
    
      grid.getSelectionModel().selectRow(index);
      grid.startEditing(index,1);
  3. #3

    Thanx.. But how to insert at the bottom instead of Top

    Dear Vladimir,

    Thanx for the solution. that worked like a charm.

    Can you please tell me that when i add a new row then the newly added row get added at the top of the grid.
    Instead i want it the other way. I mean the newly added row should always be added at the bottom.

    Here my code..
      var grid = grdRoles;
      grid.stopEditing();
      grid.insertRecord();
      grid.getView().refresh();
      grid.getSelectionModel().selectRow(0);
      grid.startEditing(0,1);
    How can i achieve this?

    Regards,
    Huzefa
  4. #4

    Any Idea??

    Guys any Idea???
  5. #5
    Use addRecord or pass index of last row to the insertRecord
  6. #6

    Thanx a lot

    How to mark this thread as completed??
  7. #7
    Don't worry, we mark thread as closed only on the Premium Help forum.
  8. #8
    Thanks works for me too!

Similar Threads

  1. how get selected index value of radiogroup
    By abhi_sheklohiya in forum 1.x Help
    Replies: 3
    Last Post: Mar 29, 2012, 10:12 PM
  2. Gridpanel = Get Selected Row Index - Client Side
    By Tbaseflug in forum 1.x Help
    Replies: 1
    Last Post: Sep 15, 2009, 11:23 PM
  3. Replies: 6
    Last Post: Jul 31, 2009, 1:45 PM
  4. [CLOSED] selected index
    By speedstepmem4 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 29, 2009, 7:46 AM
  5. [CLOSED] Selected index -1
    By speedstepmem4 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Apr 19, 2009, 3:26 AM

Tags for this Thread

Posting Permissions