[CLOSED] event store

Expedited help for Extensible support subscribers. Anyone can reply, but only subscribers can start new topics and get expedited help.

[CLOSED] event store

Postby frimfram » Fri Aug 16, 2013 7:05 pm

Hello,

We are trying to destroy calendar panel object and create new one as user navigates to different places in the UI. The autoDestroy flag of the event store is set to true, but the store is not getting reset/recreated. Do you know what we can do to reset the event store for the new calendar panel?

Thanks.
frimfram
Premium Member
Premium Member
 
Posts: 3
Joined: Wed May 08, 2013 3:23 pm

Re: event store

Postby brian.moeskau » Fri Aug 16, 2013 8:57 pm

Can you give me a few more details?

- What versions of Ext and Extensible are you using
- Are you explicitly destroying the store(s), or the CalendarPanel, or some other container? Or is it implicit (e.g. a container that auto-destroys)?

Generally speaking, the CalendarPanel should not automatically destroy its store when it is destroyed. The CalendarPanel does not create the store itself -- the store is created externally and set as a config, and can be bound to other components at any time. The expectation is that (generally-speaking) stores should be destroyed explicitly if desired, and not assumed to be destroyed by components that reference them.

The Ext docs describe autoDestroy in relation only to DataViews (I assume that's probably pretty out of date) -- maybe they've also implemented it more broadly by now. However, I would still argue against any component destroying its reference to a store unless the component itself is the creator of the store and it's only used internally to the component (which is typically not the case).
Personal Blog: Extraneous / Twitter: @bmoeskau / Meetup: Austin Bleeding Edge Web
User avatar
brian.moeskau
Site Admin
Site Admin
 
Posts: 1344
Joined: Sat Sep 18, 2010 5:00 pm
Location: Austin, Texas

Re: event store

Postby frimfram » Mon Aug 19, 2013 1:52 pm

Hello,

I'm using Extensible 1.5.2.

There's a parent panel with border layout, and we put the calendar panel in the center region like this:

ParentPanel -> panel with border layout with
{
region: 'center',
xtype: 'extensible.calendarpanel',
collapsible: false,
activeItem: 3, // month view
eventStore: Ext4.create('Extensible.calendar.data.EventStore', {autoLoad: true}),

.... //some more codes
}

Then when the user navigates to some other UI, the parent panel and calendar panel are destroyed (I verified that they were destroyed) Parent panel is explicitly destroyed (parentPanel.destroy()) and then in the 'destroy' event, I call removeAll() to make sure all sub-panels are destroyed.

Then the user wants to see calendar for some object (different data from the first calendar). so we create a new parent calendar panel and show it.

It seems Store is re-used and there are two problems caused by it:
- old data from first calendar show up in the second calendar
- there's javascript error -> problem getting/setting inner html of first calendar that is now destroyed

There are two approaches for us to take - I don't know what's a better approach and I would appreciate your recommendation.

1. keep reusing the store as is
But to make this work, we have to always delete existing data after store load. I found store.removeAll but it seems to remove data from the database as well so we cannot use this one.

2. somehow destroy store and create new one
I haven't been able to find proper way to 'destroy' store. also, when we create a new store, how do we make sure that the store is pointing to the right calendar panel?

thanks
frimfram
Premium Member
Premium Member
 
Posts: 3
Joined: Wed May 08, 2013 3:23 pm

Re: event store

Postby brian.moeskau » Mon Aug 19, 2013 9:42 pm

I created a test case that can be dropped into the existing Extensible examples folder and run. It works as expected for me. Does it work for you? If so, can you modify it to fail per your application? I can't guess what the problem might be without some code to debug.

Code: Select all
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript" src="../../Extensible-config.js"></script>

<script type="text/javascript">

Ext.Loader.setConfig({
    enabled: true,
    disableCaching: false,
    paths: {
        "Extensible": "../../src",
        "Extensible.example": ".."
    }
});

Ext.require('Extensible.calendar.CalendarPanel');

Ext.onReady(function(){
    var getStore = function() {
        return Ext.create('Extensible.calendar.data.MemoryEventStore', {
            data: Ext.create('Extensible.example.calendar.data.Events')
        });
    };
   
    var calendar;
   
    var createCalendar = function() {
        if (calendar) {
            calendar.destroy();
        }
        calendar = Ext.create('Ext.Panel', {
            title: 'Destroy Test',
            renderTo: document.body,
            width: 700,
            height: 500,
            layout: 'border',
            items: [{
                region: 'center',
                xtype: 'extensible.calendarpanel',
                eventStore: getStore()
            }]
        });
    }
   
    Ext.create('Ext.Button', {
        renderTo: document.body,
        text: 'Create New Calendar',
        handler: function() {
            createCalendar();
        }
    });
   
    createCalendar();
});


</script>

</head>
<body>

</body>
</html>
Personal Blog: Extraneous / Twitter: @bmoeskau / Meetup: Austin Bleeding Edge Web
User avatar
brian.moeskau
Site Admin
Site Admin
 
Posts: 1344
Joined: Sat Sep 18, 2010 5:00 pm
Location: Austin, Texas

Re: [DISCUSS] event store

Postby frimfram » Tue Aug 20, 2013 12:27 pm

Hi,

Thanks for the sample codes. I realize now that part of my problem is that there's only one store created since eventStore was set during class declaration. So I changed the codes to set event store during initcomponent and the app works better. However, this means that I'm creating new store every time i create calendar panel, but app is working ok for now.
frimfram
Premium Member
Premium Member
 
Posts: 3
Joined: Wed May 08, 2013 3:23 pm

Re: [DISCUSS] event store

Postby brian.moeskau » Wed Aug 21, 2013 9:36 pm

Creating new stores each time is OK. They are intended to be bound to components, so it makes sense that they can come and go as components are created and destroyed.
Personal Blog: Extraneous / Twitter: @bmoeskau / Meetup: Austin Bleeding Edge Web
User avatar
brian.moeskau
Site Admin
Site Admin
 
Posts: 1344
Joined: Sat Sep 18, 2010 5:00 pm
Location: Austin, Texas


Return to Premium Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron