drb
6 Nov 2012, 4:24 PM
Touch 2.1.0-rc2
In Touch 2.0.1.1 one can bring up a modal Ext.Panel using showBy() on a NestedList item. This fails in 2.1.0-rc2.
Ext.setup({
onReady: function () {
var data = {
text: 'Groceries',
items: [{
text: 'Sparkling',
gp: "S",
leaf: true
}, {
text: 'Still',
gp: "S",
leaf: true
}, {
text: 'Deep',
gp: "D",
leaf: true
}, {
text: 'Muddy',
gp: "M",
leaf: true
}, {
text: 'Ale',
gp: 'A',
leaf: true
}]
};
Ext.define('ListItem', {
extend: 'Ext.data.Model',
config: {
fields: [{
name: 'text',
type: 'string'
}, {
name: 'gp',
type: 'string'
}]
}
});
var store = Ext.create('Ext.data.TreeStore', {
model: 'ListItem',
defaultRootProperty: 'items',
root: data
});
var ver21 = Ext.version.version >= "2.1";
var nestedList = Ext.create('Ext.NestedList', {
fullscreen: true,
title: 'Groceries',
displayField: 'text',
store: store,
listeners: {
leafitemtap: function (nlist, list, index, listElem, record, e, opts) {
console.log("leafitemtap: " + record.get("text"));
var target;
if (ver21) {
target = listElem.element.down(".x-list-item-body"); // ".x-list-item-inner"
} else {
target = listElem.down(".x-list-item-label");
}
var onTop = (target.getPageBox().top > 70);
var sp = Ext.create("Ext.Panel", {
cls: "b-context-menu " + (onTop ? "b-top" : "b-bottom"),
modal: true,
hideOnMaskTap: true,
items: [
{
xtype: "segmentedbutton",
items: [{ text: "A" }, { text: "B" }, { text: "C"}],
listeners: {
toggle: function (ctl, button, isPressed) {
alert(button.getText());
sp.destroy();
}
}
}
],
listeners: {
hide: function () {
sp.destroy();
}
}
});
if (onTop) {
sp.showBy(target, "bc-tc?"); // bc-tc? comes out 10 px to high. tc-bc? is 10 px to low
} else {
sp.showBy(target, "tc-bc?"); // bc-tc? comes out 10 px to high. tc-bc? is 10 px to low
}
}
}
});
}
});
To be completely honest, in 2.0.1.1, it generates a warning: [WARN][Ext.Container#setModal] You have specified a modal config on a container that is neither centered nor has any positioning information. Setting to top and left to 0 to compensate. sencha-touch-all-debug.js:26047
Thanks
David
In Touch 2.0.1.1 one can bring up a modal Ext.Panel using showBy() on a NestedList item. This fails in 2.1.0-rc2.
Ext.setup({
onReady: function () {
var data = {
text: 'Groceries',
items: [{
text: 'Sparkling',
gp: "S",
leaf: true
}, {
text: 'Still',
gp: "S",
leaf: true
}, {
text: 'Deep',
gp: "D",
leaf: true
}, {
text: 'Muddy',
gp: "M",
leaf: true
}, {
text: 'Ale',
gp: 'A',
leaf: true
}]
};
Ext.define('ListItem', {
extend: 'Ext.data.Model',
config: {
fields: [{
name: 'text',
type: 'string'
}, {
name: 'gp',
type: 'string'
}]
}
});
var store = Ext.create('Ext.data.TreeStore', {
model: 'ListItem',
defaultRootProperty: 'items',
root: data
});
var ver21 = Ext.version.version >= "2.1";
var nestedList = Ext.create('Ext.NestedList', {
fullscreen: true,
title: 'Groceries',
displayField: 'text',
store: store,
listeners: {
leafitemtap: function (nlist, list, index, listElem, record, e, opts) {
console.log("leafitemtap: " + record.get("text"));
var target;
if (ver21) {
target = listElem.element.down(".x-list-item-body"); // ".x-list-item-inner"
} else {
target = listElem.down(".x-list-item-label");
}
var onTop = (target.getPageBox().top > 70);
var sp = Ext.create("Ext.Panel", {
cls: "b-context-menu " + (onTop ? "b-top" : "b-bottom"),
modal: true,
hideOnMaskTap: true,
items: [
{
xtype: "segmentedbutton",
items: [{ text: "A" }, { text: "B" }, { text: "C"}],
listeners: {
toggle: function (ctl, button, isPressed) {
alert(button.getText());
sp.destroy();
}
}
}
],
listeners: {
hide: function () {
sp.destroy();
}
}
});
if (onTop) {
sp.showBy(target, "bc-tc?"); // bc-tc? comes out 10 px to high. tc-bc? is 10 px to low
} else {
sp.showBy(target, "tc-bc?"); // bc-tc? comes out 10 px to high. tc-bc? is 10 px to low
}
}
}
});
}
});
To be completely honest, in 2.0.1.1, it generates a warning: [WARN][Ext.Container#setModal] You have specified a modal config on a container that is neither centered nor has any positioning information. Setting to top and left to 0 to compensate. sencha-touch-all-debug.js:26047
Thanks
David