[CLOSED] GridPanel getSelectionModel().Select

  1. #1

    [CLOSED] GridPanel getSelectionModel().Select

    Trying to select a row in javascript by calling grid.getSelectionModel().selectById(id) as I have seen in 2.x examples, but apparently this has been deprecated though I can't find a reference in breaking changes. Also tried grid.getSelectionModel().Select(id) but that isn't defined either. What is the new method, it is not apparent from searches on this forum.
    Thanks.
    Last edited by fabricio.murta; Jun 29, 2017 at 4:01 PM.
  2. #2
    Hello @rmelancon!

    You probably are trying something out of ordinary. It works just fine in this example: Grid Panel - Simple // Direct

    Load the example, open your browser's developer tools (F12 key, usually), on console tab, send the command:

    App.GridPanel1.getSelectionModel().select(2)
    Then the selection happens. Maybe if you elaborate on your report, with a test case showing your exact scenario, we could help you further.
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Yeah, so .select(2) works but .selectById(id) gives the error .selectById is not a function. So my assumption is that .selectById has been replaced by some other function or just isn't an option anymore. Looking at the sencha docs it looks like you can call .select with record instance or index, but apparently not by id, so what is the replacement for .selectById? or how would I get the row number of a certain id in order to select a specific row?
    Last edited by rmelancon; Jun 28, 2017 at 1:42 PM.
  4. #4
    Hello @rmelancon!

    This probably was removed from the selection model as it was not really the role of selectionmodel to know about what is the ID field of a record.

    So something like this would have the selection model's .selectById() behavior:

    var selModel = App.MyGrid.getSelectionModel(),
        store = selModel.getStore(); // get the store that is relatd to that selection model
    
    selModel.select(store.getById(2)); // assuming you have a record with ID '2' on your store, of course.
    You may want to check store.getById() returns null to display a message about non-existing record.

    Well, I hope this helps!
    Fabrício Murta
    Developer & Support Expert
  5. #5
    Perfect, that's what I was looking for. Thanks!
  6. #6
    Thanks for the feedback, glad the answer was helpful!
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. Mvc.Ext.Net Gridpanel GetSelectionModel is null
    By rushking in forum 3.x Help
    Replies: 2
    Last Post: Oct 09, 2015, 8:56 AM
  2. Replies: 0
    Last Post: Mar 04, 2013, 9:30 AM
  3. [CLOSED] GridPanel check row on select ( Multiple select)
    By FpNetWorth in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 12, 2013, 12:23 PM
  4. Replies: 4
    Last Post: Oct 11, 2011, 2:42 AM
  5. Replies: 2
    Last Post: Mar 15, 2010, 2:58 PM

Posting Permissions