-
8 Dec 2011 9:27 AM #1
Unanswered: getById don't work after additional load store
Unanswered: getById don't work after additional load store
I am using some custom paging with my store, so I'm manually calling store.load() with params after a correct event occurs. However, after loading additional data I can't use getById function to retrieve new records. It is returning "null" (which is strange since according to docs it should return undefined if no record is found).
My store is loading data in json format via ajax proxy.
So calling
return initial data set, and I can retrieve records using getById methodCode:App.stores.BookingStore.load();
after an event I callCode:App.stores.BookingStore.getById(int)
and console.log(App.stores.BookingStore) show that records were pulled from json and inserted to store in correct way. But calling again getById with id on some new records returns null.Code:App.stores.BookingStore.load({ start: monday, addRecords: true });
How should I proceed, is there a method I should call after loading store with new data? Or maybe some property to set?
-
9 Dec 2011 7:00 AM #2
Hi Marrbacca.
The load method is used to load the store data by its proxy, so maybe are you looking for the loadData function?
However, can you post your model configuration?Sencha Inc
Andrea Cammarata, Solutions Engineer
CEO at SIMACS
@AndreaCammarata
www.andreacammarata.com
github: https://github.com/AndreaCammarata
-
9 Dec 2011 7:39 AM #3
Thanks you for your answer.
About it, I do want to load new data using proxy because on each page I want to load new set of records from mysql so the load() method seems right for me...
But of course, I'm posting model declaration:
Don't bother with this long field list, this is related to another issue I'm having (can't set up the belongsTo association on models)Code:App.models.BookingModel = Ext.regModel('BookingModel', { idProperty: 'bookingID', fields: [ 'bookingID', 'clientID', 'stylistID', 'salonID', 'serviceID', 'startDate', 'splitStartDate', 'splitEndDate', 'endDate', 'status', 'status_name', 'clientNotes', 'stylistNotes', 'reminderSent', 'charge', 'offset', 'client_firstName', 'client_lastName', 'client_email', 'client_phone1', 'client_extension1', 'client_phone2', 'client_extension2', 'client_workPh', 'client_workExt', 'client_address1', 'client_address2', 'client_city', 'client_province', 'client_country', 'client_reminderType', 'client_postal', 'client_noteID', 'client_referredBy', 'client_quickLogin', 'client_creationDate', 'client_modifiedDate', 'client_birthDate', 'client_note', 'service_categoryID', 'service_name', 'service_duration', 'service_processDuration', 'service_finishDuration', 'service_cost', 'service_clientBookable', 'service_priceFirm', 'service_note' ], proxy: { type: 'rest', url : 'includes/data_api', format: 'php', appendId: true, extraParams: { model: 'Booking' }, reader: { type: 'json', root: 'items' } } });
-
13 Dec 2011 7:13 AM #4
Any ideas on that?
I found another stange thing on that
If I do
and then console.log(App.stores.BookingStore) I see store with one correct item in data.Code:App.stores.BookingStore.clearFilter(); App.stores.BookingStore.filter('bookingID', url.token); App.stores.BookingStore.load();
but if I do console.log(App.stores.BookingStore.data.items) it gives me empty array.
Maybe I'm forgotting some config options or something...
My store configuration:
Code:App.stores.BookingStore = new Ext.data.Store({ model : 'BookingModel', sorters: 'startDate', autoLoad: false, getGroupString : function(record) { var dt = new Date(record.get('startDate')); return Ext.util.Format.date(dt, 'D Y M j'); }, load: function(options) { if (options == undefined) options = new Object(); options.start = this.start; options.page = this.currentPage; return Ext.data.Store.superclass.load.call(this, options); } });


Reply With Quote