View Full Version : lists and getSelectedRecords() can't handle integers

17 Oct 2011, 1:24 PM
I think there is a problem with the way that getSelectedRecords() returns
the underlying data object, and fields that are of type 'int'. (basicly,
I'm building a shopping cart where i need to update the quantity of
selected line items via some external buttons).

When I try to get/set a field, (when a user selects a line in a list), I
have this code:

if ( saleList.getSelectedRecords().length > 0 ) {
var myrec = saleList.getSelectedRecords()[0];

// myrec.data.count is always "0" for some reason ?
console.log ( myrec.data.count );

So, if the 'count' field is of type 'int', the value is always 0. 'strings' are
returning correctly. It seems that getSelectedRecords() renders the
object in odd ways and doesn't like ints.

My data model looks like this :

model: Ext.regModel('', {
fields: [
{name:'type', type:'string'},
{name:'value', type:'string'},
{name:'name', type:'string'},
{name:'count', type:'int'},
{name:'total', type:'int'}

And I know it isn't the datamodel, because if i do the same thing with the
initial touch handler, I can get to the int values. it seems that 'getAt'
returns the right kind of object. (and i can't use the event handler,
because I need to get at this line AFTER the initial 'itemtap' event)

saleList.on( 'itemtap' , function( t , i , elem , ev ) {

// find the record/line item
var myrec = saleData.getAt( i ) ;

// update a field
orderTot.setText( myrec.data.count )

Is this a bug ? Or am I missing something obvious ?

Or, am stuck with mess indirect workarounds like this :

var selected = list.getSelectedRecords(),
if (selected.length > 0) {
idx = store.indexOf(selected[0]);

// now go do stuff with the actual store record