Hybrid View
-
7 Jul 2011 5:59 AM #1
[EXTJSIV-3455] Store: get index of record after add
[EXTJSIV-3455] Store: get index of record after add
hey,
i tried to get the index of a record i added to store.
But if i do a store.indexOfId(...) after store.add(...)/store.insert(...), it always returns "-1"...
thx for help,
j4y
-
7 Jul 2011 6:14 AM #2
The record doesn't have an index but if you do an add the index will be 0. (Ext.data.Store-method-add)
If you do an insert then you can define the index. Ext.data.Store-method-insert
-
7 Jul 2011 6:20 AM #3
Thats not the problem

The record is definitely added to store. Also if i define a special index with store.insert, the record was successfully added to store (its displayed in dataview).
The problem is, that store.indexOfId() or store.indexOf() returns "-1", althought record is in store
-
7 Jul 2011 7:18 AM #4
That is because the store doesn't add an index to it.
If you look at it in firebug, in your console, you will see the records but you will see that the added row has no index.
Maybe this is a bug or maybe it was intented.
-
7 Jul 2011 8:05 AM #5
i can't see any reason why it could be intented

maybe anybody has got another solution for my problem:
The store is used in an Ext.view.View.
After adding a new record to store, i want to select that new record in dataview automatically....
-
7 Jul 2011 8:13 AM #6
@J4Y-
Can you post how you are creating the record, and what ID you are using when calling store.indexOfId(??)?"be dom-ready..."
Doug Hendricks
Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.
Got Sencha licensing questions? Find out more here.
-
7 Jul 2011 9:04 AM #7
The store has no model definition (using fields-property), so i don't create record with Ext.create...
But i also have this problem in a grid where i create a new instance of a model...PHP Code:App.getNavigationStore().add({
id: 'view_quicksearch',
name: 'Suchergebnisse'
});
App.getNavigationPanel().select(App.getNavigationStore().indexOfId('view_quicksearch'));
-
7 Jul 2011 10:58 AM #8
@J4y--
This is a bug.
in the absence of a formal Model definition(fields config), the idProperty defaults to 'id'. But the ModelManager.create method does not yet consider that. Use this override while we get this fixed:
Code:Ext.ModelManager.create = function(config, name, id) { var con = (typeof name == 'function') ? name : this.types[name || config.name]; return new con(config, id || config[con.prototype.idProperty]); };"be dom-ready..."
Doug Hendricks
Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.
Got Sencha licensing questions? Find out more here.
-
7 Jul 2011 10:02 PM #9
thx dude, you saved my day

but this occurs also with a formal model definition:
PHP Code:var model = Ext.ModelManager.create({}, GLOBALS.MODEL_NAME_EMPLOYEE);
....update fields....
Ext.getStore(GLOBALS.STORE_ID_EMPLOYEE).insert(0, model);
alert(model.get('id'));
alert(Ext.getStore(GLOBALS.STORE_ID_EMPLOYEE).indexOfId(model.get('id')));
-
7 Jul 2011 10:13 PM #10
Nice to see this became a bug, it was just planning to report this bug.

You found a bug! We've classified it as
EXTJSIV-3455
.
We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.


Reply With Quote

