PDA

View Full Version : Remember state of collapsible panel


marceloverdijk
05-20-2007, 02:54 AM
Hi,
I have an application with a BorderLayout containg a West (for navigation), North and Center panel.

The West panel is a collapsible panel which can be hidden by the user.

Currenty when I click a link for a new page, the complete page is rebuild including the navigation panel. This causes the panel to be my default non-collapsed state, also if the user collapsed it before. I guess it makes sense as I didn't do anything to remember it's state...

2 questions:

1.
Everytime reloading the complete layout is not a good idea I think (performance). Should using IFrames advisable?
I guess when using IFrames, and this not reloading the navigation - the navigation will stay collapsed.

2.
Is there a way to say to the navigation panel to keep it's state automatically?


Cheers,
Marcel

jsakalos
05-20-2007, 04:17 AM
2.
Is there a way to say to the navigation panel to keep it's state automatically?
Put the following somewhere at the beginning of your app:



// initialize state manager, we will use cookies
Ext.state.Manager.setProvider(new Ext.state.CookieProvider());

and just before your endUpdate():



layout.restoreState();
layout.endUpdate();

marceloverdijk
05-20-2007, 04:28 AM
Thanks agin Jozef for your quick reply.

Keeping state isn't that difficult... Thanks.

I noticed you are very active on this forum, helping but more important also giving advise on architecture etc.
As I'm new to Ext (and only used JavaScript for simple things), I'm wondering what your views is on my other question if it's smart to keer setting up the navigation panel for every link to another page, or to use IFrames, or maybe use something else?


Cheers,
Marcel

jsakalos
05-20-2007, 04:33 AM
Well,

I don't know the nature of your app, what it should do and what's your goal. So the only stupid answer I can give you: Maybe yes, maybe no. Kidding... ;)

If you explain more and if I know I'll be glad to give you an advice.

marceloverdijk
05-20-2007, 05:37 AM
Thanks Jozef,

The nature of my application is a CRUD application.
So in the navigation panel (more like a menu) I like to display links to my entities. Those links will show up a page (in Center) which displays a list/grid of the specific entities. From there you can select a record and go the edit page, you can push a link to create a new entity.

All the time browsing to the application I like to have the same layout (including header, menu and center). Header and navigation will be the same, only the content in Center will change.

So currently, because I'm just experimenting, I just load everything if I navigate to another page. But always setting up the BorderLayout sounds like overhead to me....

jsakalos
05-20-2007, 06:27 AM
I'll keep asking... ;)

The nature of my application is a CRUD application.CRUD = Create, Retrieve, Update, Delete, yes? But what? Records in a database? Files? Another entities?

Those links will show up a page (in Center) which displays a list/grid of the specific entities.What entities? Records? Complex html fragments? Something else?


I'm just experimentingThat's absolutely fine. My over 25 years of programming experience says that one has to experiment. On the other hand, it never worked for me to be too general in experimenting especially when I was trying to learn something new. In such cases I was always trying to learn and program a simple specific thing. For example: I want an icon to appear here, I want a list of person first and last names, etc.

Only later when I got basic skill of putting an icon or list there I'd started to generalize. For example: Well, if I can put list of persons here let's think how to put a general list here; list of anything.

Got the idea?

Scholarly attitude is: General to specific. Practical attitude is: Specific to general.

This always worked for me.

marceloverdijk
05-20-2007, 07:19 AM
CRUD is indeed create, retrieve, update, delete.
The Entity is the object I will store records for in the database.

So in fact the Center will always be a action of display records (R), or creating a record (C) etc. for a specific entity. Not that rocket science at all.

jsakalos
05-20-2007, 07:24 AM
Have you seen this? Just look ! (http://extjs.com/forum/showthread.php?t=6153)

marceloverdijk
05-20-2007, 07:48 AM
Yes ;) and it looks great!

jsakalos
05-20-2007, 08:39 AM
So I'd do it like this:

Links, buttons, whatever in left panel
Clicking it would open (optionally new) tab created grid loaded data
The CRUD functionality would be implemented in the grid (header/footer)To make it ease I'd extended the EditorGrid class with the CRUD toolbar.

Hope it helps.

marceloverdijk
05-20-2007, 01:08 PM
Thanks, this is also my idea.

But would you reload the menu each time. Or use IFrames?

jsakalos
05-20-2007, 01:35 PM
No reload. Just initial load. Everything else handled by Ext.

marceloverdijk
05-21-2007, 01:42 AM
I keep questioning ;)

Initial load makes sense, as it's not needed to init the general layout, navigation etc.

To only load the Center panel I can use IFrames - the Ext documentation site is also doing this -, this is easy.
Is this the way you are doing it also? From your post I have the feeling that you are using some Ext js features to this.... But this would mean I have to put some additional logic to all my links?

jsakalos
05-21-2007, 04:56 AM
I'm not using iframes yet as I haven't need it in my app yet, but I will.

Re logic on links: Yes or no (Germans have nice word "jain"). I still have very foggy idea as to what are you trying to do. If you say "link" it implies to some degree that it's "link to an (another) page". Looking at extjs doc there is no need to have any "logic" on links on the west side (except they are in tree and they must have proper src attribute) as west is independent from center and vice versa.

Should this be your case no "logic" is needed.

On the other hand, you've said in some of your previous posts that center will be grid to manipulate a database table. In this case you do not need "link" on the west the "button" is enough. Click on it could (re)create the grid in center and load it with data.

You do not need any iframes in this scenario.

A few questions: Are you working on anything specific? I mean an app for you or for your customer? Or, is it a general database management system? Or, is this just theoretical discussion on what's possible?