Ask our community for help with v1.x versions of our products.

Post by rapas »

Hi,

In our application we use RESTfull web services to handle the CRUD operations on our scheduler.

When for example an event is moved or the start- or enddatetime is changed, an update request is sent to the server.
When the save succeeds, we sent back the event data for this changed event, because the server side business ruling may have had effect on the event properties (e.g. datetime may have been snapped to a certain unit of time). I see that these changes are reflected in the ui automatically.

In our situation, also related events may have been effected by the saved event. When i add the event information of the related events in the reply, i don't see the changes of the related events in the ui.
Is it possible to get the event store (and ui) updated with the changed data?

So, to explain my question with an example:
Imagine that the event store holds events 1 until 100. Then i move event 20 to another timeframe. Event 20 is now saved, but the side effect of the save is that event 30 also is moved to another timeframe. So the reply contains the (changed) data for event 20 and 30.
Expected to see both changes in the scheduler, but we see only the changes for event 20.

Post by mats »

Simply listen to the store 'write' event and access your custom response data and add it the store there. Should be very easy.

Post by rapas »

Thanks Mats,

I will have a look.

Post by rapas »

Hi Mats,

This indeed seems easy. I only have to add the records that i get back from the server to the eventStore.
write: function EventStore_onWrite(store, operation, eOpts) 
{
	var success=operation.wasSuccessful();
        if (success) 
        {
            Ext.each(operation.resultSet.records, function(record)
            {
            	// add the inserted or updated record to the event store.
            	// when the record already exists, it will be replaced.
       		store.add(record);
            });
        }
 }

Post by @sagardindorkar@ »

Hello mats,

I just want to ask ,this write method can update the old eventstore existing data to new data?
It automatically identify the difference and update it or it add the new data ?

my problem is i want to update the existing data of event store ..i do not want to add the data in the event store ..

Please give me solution ..

thanks in advance..

Post by mats »

To replace it completely, please see 'loadData' method. Try browsing the Ext JS docs, you can find all the answers there. http://docs.sencha.com/extjs/4.2.2/#!/a ... d-loadData

Post by @sagardindorkar@ »

Thanks mats for reply ..

Yes, loadData method replace it completely but i want update the particular data corresponding to one resource Id and that date..

after that it should reflect the user interface of scheduler..

right now data is update in database but scheduler view is not showing the updated data i am doing like this here is my code:
 data.Result.forEach(function(item, index, totalitem) {
                var abd = Ext.getCmp('scheduler').eventStore;
                abd.loadData(item,true);
                Ext.getCmp('scheduler').getSchedulingView().refresh();
            })

it only show the loading mask...

Thanks in Advance..

Post by mats »

If you use 'loadData', no need to manually call refresh. Your approach should work fine, any problems with it?

Post by @sagardindorkar@ »

thanks mats for ur reply,

No, It is not showing the updated data on the scheduler it continuously showing the loading mask.
because i have used the following line for loading mask..
Ext.getCmp('scheduler').el.mask('Loading data..', 'x-mask-loading');
and when i remove that line of code..it dosen't show anything and we not experiencing any change on scheduler.

Post by mats »

Ok, then there's some bug in your incoming data perhaps. If you can provide a clear test case (using only static JS data for the server traffic) we can try to take a look.

Post Reply