Sproutcore SC.MenuPane keep/remember/visible selected item - sproutcore

I have a working popup button with menu 2 options, and need to 'keep/remember' the selected item visible to the user, in other words, the next time the menu pops up, the previous made choice should be visible (eg highlighted).
selectMenuButton: SC.PopupButtonView.extend({
layout: {left:10, bottom: 10, height: 18, width:100},
controlSize: SC.SMALL_CONTROL_SIZE,
title: 'Menu',
menu: SC.MenuPane.extend({
layout: { width: 150 },
items: [
{ title: 'option1', checkbox: YES, action: 'action1',target: 'App.Controller1'},
{ title: 'option2', checkbox: NO, action: 'action2',target: 'App.Controller2'}
]
}),
}),
I tried classnames css .active or .sel, but that didn't work.
Please some advice, thanks in advance.

Related

Render the screen when clicked on stack navigator tab

I crated a tab view using TabNavigator. Here is the library I used. Total I have 3 tabs. So Initial tab is loading & rendering fine without hassle. But the problem is coming with 3rd Tab. I checked with console.log() in every method in that 3rd tab component. Every method is executing but not showing results ( Showing blank screen) until I interact with it. When I start interacting with it, then only data is re-rendering(I think so).
How can I solve this problem? Any help?
Thanks
I solved it by configuring tab navigator with prop lazy true. Below is the code I modified. It's working now.
const TabView = TabNavigator({
feed: { screen: Feed },
info: { screen: Info },
members: {screen: Members}
}, {
tabBarPosition: "top",
tabBarOptions: {
activeTintColor: "#4A90E2",
inactiveTintColor: "#4A4A4A",
style: {
backgroundColor: 'white',
height:56,
alignItems: 'center',
shadowColor: '#000000',
shadowOpacity: 0.1,
shadowRadius: 0,
shadowOffset: {
height: 2,
width: 1
}
},
tabStyle: {
height: 40,
},
labelStyle: {
fontSize:12,
fontFamily:'HelveticaNeue-Medium'
}
},
lazy:true
});

Attempting to clear tableView just doubles the content

I am attempting to update my table view with updated data but whenever I try to clear it using either
tagsTable.setData();
or
tagsTable.setData([]);
or
tagsTable.data = null;
and then re-apply the updated data using
tagsTable.setData(TagsData);
It never clears the table originally so the new data is just added to the end of the table, so I have the old data as well as the new data in the 1 table.
Any one know whats wrong or how to fix it?
Here's a simple (classic Titanium) app that shows clearing and re-filling the table's data property via some buttons. I'd triple-check the validity of your TagsData sections/rows to make sure everything within the array is being set properly.
var
win = Ti.UI.createWindow({
title: "Table Funs",
layout: "vertical",
backgroundColor: "#ffffff"
}),
navwin = Ti.UI.iOS.createNavigationWindow({
window: win
}),
table = Ti.UI.createTableView(),
clearButton = Ti.UI.createButton({
title: "Clear Table",
width: Ti.UI.FILL,
height: 44,
backgroundColor: "#f4f4f4",
color: "red",
bottom: 1
}),
fillButton = Ti.UI.createButton({
title: "Fill Table",
width: Ti.UI.FILL,
height: 44,
backgroundColor: "#f4f4f4",
color: "blue",
bottom: 1
}),
tableData = [];
// Fill up tableData array with rows
tableData.push(Ti.UI.createTableViewRow({ title: "Hey" }));
tableData.push(Ti.UI.createTableViewRow({ title: "this" }));
tableData.push(Ti.UI.createTableViewRow({ title: "is" }));
tableData.push(Ti.UI.createTableViewRow({ title: "a" }));
tableData.push(Ti.UI.createTableViewRow({ title: "table" }));
clearButton.addEventListener("click", function() {
Ti.API.debug("Clicked clear button.");
table.setData(null);
return;
});
fillButton.addEventListener("click", function() {
Ti.API.debug("Clicked fill button.");
table.setData(tableData);
return;
});
// Fill table with our data
table.setData(tableData);
// Build window
win.add(clearButton);
win.add(fillButton);
win.add(table);
navwin.open();

How to use custom content to show the grid's tooltip?

How to use custom content to show the grid's tooltip? I want to show the tooltio ofcoloumn 2 and coloumn 3 ,and the content is a span which id called spanid or div which is called divid?
var tooltip = $("#Grid").kendoTooltip({
filter: "td",
width: 120,
position: "top",
content: value
}).data("kendoTooltip");
I try to write this,but it seems wrong.
var tooltip = $("#Grid").kendoTooltip({
filter: "td[3n]||td[2n]",
width: 120,
position: "top",
content: divid.html
}).data("kendoTooltip");
This is a working code for my scenario, it will work tool tip for all product names with class pLink
$(".pLink")
.kendoTooltip(
{
content: kendo.template($("#toolTipTemplate").html()),
position: "top",
width: "auto",
height: "auto",
animation: {
close: { effects: "fadeOut zoom:out", duration: 300 },
open: { effects: "fadeIn zoom:in", duration: 300 }
}
});
<script id="toolTipTemplate" type="text/x-kendo-template">
<p class="tooltipProductName">#=target.data('title')#</p>
</script>
//show the tooltip
tooltip = $("#grdData").kendoTooltip({
filter: 'td:not(:first-child, :nth-child(2), :empty)',
})
this will allow you to select first column , second column and it will also filter out empty cells. You can use the nth child selector. As this is a CSS3 selector, it will work from IE9+, chrome and firefox won't be an issue.
Hope this helps !

Prevent movement of user interface when keyboard appears

I'm working on a little app which uses Sencha Touch 2 for the user interface. Right now I'm running it in Safari on my iPad and iPhone.
My problem is that whenever I tap a text field, Safari brings up the virtual keyboard and pushes the whole web view upwards, off the screen.
This doesn't look very natural, since the top-toolbar is not visible anymore.
Here are two screenshots which demonstrate the problem.
In the second screenshot you can see the effect when the keyboard is visible.
Is there a way to prevent this behavior, and have Safari resize the user interface instead?
Unfortunately, Apple wants this behavior, but someone suggested a little hack using window.scrollTo():
listeners: {
focus: function() {
window.scrollTo(0,0);
}
}
Putting this code in launch function in app.js worked for me:
if (Ext.os.is.Android) {
Ext.Viewport.on('painted', function () {
Ext.Viewport.setHeight(window.innerHeight);
});
}
if (Ext.os.is.iOS) {
Ext.Viewport.on('painted', function () {
Ext.Viewport.setHeight(window.innerHeight);
});
}
I have found a solution that works for me.
You move the topbar into the container.
xtype: 'container',
docked: 'top',
height: '100%',
html: '',
itemId: 'MyContainer',
width: '100%',
items: [
{
xtype: 'titlebar',
docked: 'top',
itemId: 'topBar',
title: 'Obec Webchat',
layout: {
type: 'hbox',
align: 'start'
},
items: [
{
xtype: 'button',
action: 'back',
id: 'BackButton',
itemId: 'BackButton',
margin: '5 70% 5 15',
ui: 'back',
text: 'Home'
}
]
},
{
xtype: 'container',
docked: 'bottom',
height: '95%',
html: '<iframe src="http://webim.obec.local/" width="100%" height="100%" scrolling="yes"></iframe>',
itemId: 'MyContainer1',
width: '100%'
}
]
}
Hope this helps.
You will need to call the blur() method on textfield
// Assuming the id of textfield - "textFieldId"
Ext.getCmp('textFieldId').blur();
Attempts to forcefully blur input focus for the field.
If you this using html into Sencha elements must remove something tag html. Or can you put tag in the source html code. I hope help you. :)

Reordering the subpanels of an ExtJS panel

I have an ExtJS Panel which contains a label in the first row and second row. Later i have added 4 sub panels each contains a checkbox, and 2 textfields( each sub panel in a row in the main panel). Then i have 2 Move up/Move down buttons which reorder these sub panels up/down by 1 row for each click of the up/down buttons. I am able to layout the main panel with all the subpanels but stuck at reordering the subpanels. How to handle this(reordering the subpanels) functionality in ExtJS?
The trick to change panel elements dynamically is to call doLayout function after change.
Not prettiest but working example of your problem:
var Panel1 = Ext.create('Ext.form.Panel', {
title: 'first',
items: [{
fieldLabel: 'text1',
xtype: 'textfield'
}, {
fieldLabel: 'text2',
xtype: 'textfield'
}, {
xtype: 'checkbox'
}]
})
var Panel2 = Ext.create('Ext.form.Panel', {
title: 'second',
items: [{
fieldLabel: 'text1',
xtype: 'textfield'},
{
fieldLabel: 'text2',
xtype: 'textfield'}]
})
var mainPanel = Ext.create('Ext.panel.Panel', {
title: 'main',
items: [Panel1, Panel2]
})
new Ext.Window({
width: 300,
height: 400,
layout: 'fit',
items: [mainPanel],
bbar: [{
text: 'reorder',
handler: function() {
var swap = mainPanel.items.items[0];
mainPanel.items.items[0] = mainPanel.items.items[1];
mainPanel.items.items[1] = swap;
mainPanel.doLayout();
}
}]
}).show();
This is for ExtJs 4.0.7, but trick works for earlier versions, just adjust panel creation syntax.

Resources