PDA

View Full Version : Grid SelectionModel.selectRows() does not like indexes over 10?



Mark H
30 Jun 2011, 7:22 AM
Hiya,

I've been working on an addon for a CMS called MODX which makes use of ExtJS 3.3 (and some custom extensions) to power the back-end.

So I developed a listing with options based on a grid, with a selectionmodel that I extended using some code I found on these forums to allow single clicks.

Now the client just contacted me saying the grid leads it own life and options change all the time.

You can find the complete code on Github, this is the specific panel and rest of the code for this specific grid is at the bottom of the file (CamperMgmt.gridSelectOptions): https://github.com/Mark-H/CamperManagement/blob/master/assets/components/campermanagement/js/mgr/page.newcamper.js

Basicly, the page that script is on sets a CamperMgmt.values array with all the information, and CamperMgmt.values.options is a comma separated list of options to pre-select (based on what was selected and saved before). In the Ext.onReady I'm parsing that string into a row indexes to select them with rowSelect(). All good! Except that as soon as the row index is higher than 10, for example 23, it seems to be refusing to select those, but instead just selects the last part of that number that is under 10. So instead of 23 it selects 3, and instead of 19 it selects 9 and instead of 10 it selects 0.

I came to that conclusion with the console.log() calls to see if there was something wrong with the indexOfId() calls, the optionIndices not being set properly or what else was up. But then I noticed how all selections ended up in the first bit but not later on and managed to confirm it by selecting rowindex 1,3,5,7,9,12, in which instead of selecting rowindex 12 it selected 2.
This also selects the 2nd and 3rd (rowindex 1,2) instead of rowindex 11,12 when typed into the Console:
Ext.getCmp('options-grid').getSelectionModel().selectRows('11,12')

I'm lost here :-/

I couldn't find anything about this on the forum and I don't see why it wouldn't allow rowindexes over 10.. Any one has any idea? Any help / tips appreciated! I'm still trying to completely grasp ExtJS :D

The code may be somewhat dependent on the MODX implementation of MODX, and if anybody wants to see this in action but doesn't have a MODX installation set up somewhere I could give you access to one of my installs on request..

Mark H
30 Jun 2011, 9:00 AM
Solved!

The issue was that I was passing the rowindexes as a string like so:

..selectRows('11,12')

where as it needs an array

.. selectRows([11,12])


:D