View Full Version : Best way to dynamically create panels with data from store?

4 Feb 2011, 8:50 AM
I have a survey whose questions and possible answers are stored in a database, and the number of questions in the survey can vary.

What I'd like to do is load each survey question and the multiple choice responses into a store, and then dynamically create a card for each question with a "Next" button so they can move to the next question/panel.

Well I have my store, and I can create a static number of cards with "Next" and "Back" buttons which call setActiveItem(), but I'm unsure how best to tie them together the way I describe. Can someone point me in the right direction?

4 Feb 2011, 1:09 PM

Also, is it possible to have a form that spans across all of the cards? So I can have the user go through each card and select an answer, and have them all get submitted together as part of the same form.

22 Jan 2012, 11:07 AM
One year later but I needed this today and didn't find the answer so here is my workaround:
(It works in ST 1.x)

var store = Ext.getStore('SomeStore'),
items = [];

store.each(function(model) {
var panel = new Ext.Panel({
data: model.data,
tpl: [
'<tpl for=".">',
'<div class="my-panel" id="panel-{id}">',
// here you have your items array populated with panels to use in a carousel.

Hope it helps someome.