How to get space between TableViewRow has show in above image.
Window.js
for(var i=0;i < election.length ;i++){
//
tblRow_Election[i] = Titanium.UI.createTableViewRow({
height:(Ti.Platform.osname == 'ipad')?'280':'140',
width:Titanium.Platform.displayCaps.platformWidth,
left:(Ti.Platform.osname == 'ipad')?'20':'10',
right:(Ti.Platform.osname == 'ipad')?'20':'10',
color:'red',
touchEnabled: true,
borderRadius:'4',
borderWidth:'1',
borderColor:'green',
});
data.push(tblRow_Election[i]);
}
$.tbl_ElectionList.data = data;
Window.tss
"#tbl_ElectionList":{
top:'40',
height:'auto',
backgroundColor:'transparent',
left:'10',
right:'10',
style:Titanium.UI.iPhone.TableViewStyle.GROUPED,
borderColor:'green',
separatorInsets: {
left:0,
right:0,
},
}
Window.xml
<Alloy>
<Window id="ElectionWin" class="ElectionWindow" >
<View class="container" id = "view_Election" backgroundColor="white">
<TableView id="tbl_ElectionList">
</TableView>
</View>
</Window>
</Alloy>
Unable to get gap between each row . Can any one advice me how to achieve the gap between each tableviewRow.
#All Thanks in Advance
First you have to set the separator style to none, so that you can define gaps yourself, you can set this in the table' tss, I would also not use the grouped style as this further constrains your styling:
"#tbl_ElectionList":{
top:'40',
height:Ti.UI.SIZE,
left:'10',
right:'10',
separatorStyle : Titanium.UI.iPhone.TableViewSeparatorStyle.NONE,
borderColor:'green'
}
Try adding rows that way and you should see the gaps
var containerrow = Titanium.UI.createTableViewRow({
height:(Ti.Platform.osname == 'ipad')?'280':'140',
width: Ti.UI.FILL
});
// This innerView will be set in the middle of the row
// It will hold your main row content
// We make it smaller than the row to give padding
var innerView = Ti.UI.createView({
width : '80%',
height : '80%',
color:'red',
borderRadius:4,
borderWidth:1,
borderColor:'green'
});
containerrow.add(innerView);
// Add to the table data
data.push(containerrow);
Then of course set the data as you did before.
Related
This is default style of my chart in highcharts :
I want to change position of inputs, charts that I use are from https://www.highcharts.com/ site , i want to change from input from left to right and to input from right to left with from and to texts
I want to be like this image :
How can I do that?
It's impossible to change in regular Highcharts API options, but making some changes in core code does the job.
jsFiddle demo
At Highcharts.RangeSelector.prototype.render we need to switch sequence of triggering rangeSelector.drawInput functions:
if (inputEnabled !== false) {
rangeSelector.div = div = createElement('div', null, {
position: 'relative',
height: 0,
zIndex: inputsZIndex
});
container.parentNode.insertBefore(div, container);
// Create the group to keep the inputs
rangeSelector.inputGroup = inputGroup =
renderer.g('input-group').add(group);
inputGroup.offset = 0;
rangeSelector.drawInput('max');
rangeSelector.drawInput('min');
}
In Highcharts.RangeSelector.prototype.drawInput I made some styling/creating changes here:
// Create an SVG label that shows updated date ranges and and records
// click events that bring in the HTML input.
this[name + 'DateBox'] = dateBox = renderer.label('', inputGroup.offset)
.addClass('highcharts-range-input')
.attr({
padding: 2,
width: options.inputBoxWidth || 90,
height: options.inputBoxHeight || 17,
'text-align': 'center'
})
.on('click', function() {
// If it is already focused, the onfocus event doesn't fire
// (#3713)
rangeSelector.showInput(name);
rangeSelector[name + 'Input'].focus();
});
// Create the text label
this[name + 'Label'] = label = renderer.label(
lang[isMin ? 'rangeSelectorFrom' : 'rangeSelectorTo'],
this.inputGroup.offset
)
.addClass('highcharts-range-label')
.attr({
padding: 2,
paddingLeft: 100
})
.add(inputGroup);
inputGroup.offset += label.width - 85;
I'm creating an for to create randomly textAreas but I need to know which textArea was pressed by the user.
Is there any way to enter a unique ID for each textArea?
How I create the textView:
var txtArea = Ti.UI.createTextArea({
color : '#000',
backgroundColor : 'transparent',
font: {
fontSize : 28,
fontWeight : 'normal',
},
editable : false,
textAlign : 'left',
value : a[i],
textAlign : 'center',
top : '30%',
width : '100%',
height : '100%'
});
I tried to put "id : i", but all textAreas returned the same ID.
It's not suggested to add custom properties to Titanium proxies. Here is what I would do (based on my guess of what you try to achieve):
for(var i = 0; i < 10; i++){
var txtArea = Ti.UI.createTextArea({
value : "test n " + i,
textAlign : 'left',
textAlign : 'center',
top : '30%',
width : '100%',
height : '100%'
});
(function(){
var id = i;
txtArea.addEventListener('click',function(){
console.log(id);
});
})();
}
If you want assign a numerical ID, you are in the right way but I think that you must insert all TextAreas in rows of Table view. This because you get ID from table view row not from Textarea. Your id's attemp was correct if you inserted in a table view row.
Your code for create textArea is something like this:
var txtArea = Ti.UI.createTextArea({
id: i,
value : "test n " + i,
textAlign : 'left',
textAlign : 'center',
top : '30%',
width : '100%',
height : '100%'
});
You can furthermore get the id of each row simply add a click Event Listener, in particular case:
tableViewRowName.addEventListener('click', function(e) {
console.log(e.source.id);
}
Let me know if works and not hesitate to contact me.
FULL EXAMPLE
In your controller js
var win = Ti.UI.createWindow();
var scrollableView = Ti.UI.createScrollView();
var table = Ti.UI.createTableView();
var tableData = [];
for(var i=0;i<list.length;i++){
var row = Ti.UI.createTableViewRow();
var txtArea = Ti.UI.createTextArea({
id: i,
value : "test n " + i,
textAlign : 'left',
textAlign : 'center',
top : '30%',
width : '100%',
height : '100%'
});
row.add(txtArea);
tableData.push(row);
}
table.setData(tableData);
scrollableView.add(table);
win.add(scrollableView);
win.open();
This is what i mean: in your structure you have already an empty table view.
You populate dinamically this table in your controller, with a loop (for or while it's the same).
Every iteration you push the row with the respective TextArea and at the end of loop you populate the table with setData
Regards
I'm trying to use a ScrollView (with paging enabled) in React Native to page through a series of images. Anyone know how to make the image views fill each page of the scroll view? So far I've only had luck hard coding width and height values for the image style.
Here's roughly what I'm doing:
render: function() {
return (
var images = [{ url: 'http://url/to/image.jpg' }, { url: 'http://url/to/another-image.jpg'}];
<ScrollView horizontal={true} pagingEnabled={true} style={styles.myScrollViewStyle}>
{images.map(image => {
return (
<Image source={{uri: image.url}} style={styles.myImageStyle} />
);
})}
</ScrollView>
);
}
The only way images show up is if I hardcode a width/height number in the style. I've been unable to get the Image to just flex to fill 1 whole page.
ScrollView style:
scrollView: {
flex: 1,
backgroundColor: '#000000',
}
Image style:
image: {
width:375,
height:667,
flex: 1,
backgroundColor: 'rgba(0,0,0,0)',
}
To set image dimensions use next code:
var Dimensions = require('Dimensions');
var windowSize = Dimensions.get('window');
...
image: {
width: windowSize.width,
height: windowSize.height,
flex: 1,
backgroundColor: 'rgba(0,0,0,0)',
}
I do not believe it is possible to achieve this using only Flex right now, as it is going to try to contain all the images within your container.
ScrollView does have a contentContainerStyle={} property however, so I could envision a solution being something like setting the width of the container to be (window.width * number of items) which would then allow flex:1 on each image child do what you expect.
Unfortunately there is currently no way to fetch the window width (yet) https://github.com/facebook/react-native/pull/418
At the moment it seems like hard coding dimensions is the only option.
I am trying to create a Extjs Grid with no vertical and horizontal scroll bars. it means that the grid should expand to infinity in both direction.
here is my code:
Ext.require([
'Ext.grid.*',
'Ext.data.*',
'Ext.util.*',
'Ext.state.*'
]);
Ext.onReady(function() {
Ext.QuickTips.init();
// setup the state provider, all state information will be saved to a cookie
//Ext.state.Manager.setProvider(Ext.create('Ext.state.CookieProvider'));
var cols = 50;
var colsData = [];
var fields = [];
for(var i=1;i<cols;i++){
colsData.push(
{
text : 'COLUMN - ' + i,
//flex : 1,
width : 120,
sortable : true,
dataIndex: 'COL'+i
});
fields.push(
{name: 'COL'+i, type: 'int'}
);
}
var myData = [];
//create data
for(var i=1;i<500; i++){
var subData = [];
for(var j=1;j<cols; j++){
subData.push(Math.floor((Math.random()*10000)+1));
}
myData.push(subData);
}
function change(val) {
return val;
}
// create the data store
var store = Ext.create('Ext.data.ArrayStore', {
fields: fields,
data: myData
});
// create the Grid
var grid = Ext.create('Ext.grid.Panel', {
store: store,
stateful: true,
//stateId: 'stateGrid',
autoHeight: true,
autoWidth: true,
autoScroll: false,
//containerScroll: false,
columns: colsData,
//height: 100,
//width: 600,
title: 'Array Grid',
renderTo: 'grid-example',
viewConfig: {
//stripeRows: false,
//forceFit: false
}
});
});
i'm rendering my grid to a div element so practically i don't use any layout or etc.
<div id="grid-example" class="myDiv"></div>
and the styles:
<style type="text/css">
body{
overflow: visible;
}
.myDiv{
display: block;
/*float: left;*/
overflow: visible;
}
</style>
Here is my browser's screen shot that shows the vertical scroll bar [just like I expected].
THE PROBLEM IS
There is NO horizontal scroll bar and part of columns just cut off from page and there is no way to see the data they are presenting.
i can see that extjs tries to calculate the height and the width for the grids. in case of height it's correct but for width it's not, the calculated width is equals to my browser's width, not to the sum of columns which are in the grid.
I appreciate any suggestion or words from your side, thank you.
any one can help me with that?
I solved this problem by registering a numbers of listeners on viewConfig.viewready, grid.columnresize and etc. So we calculate the total width of columns each time we render a grid or resize/change a visibility of a column. consequently, I expand the grid to the calculated size. something like:
var grid = Ext.create('Ext.grid.Panel', {
store: store,
stateful: true,
autoHeight: true,
columns: colsData,
title: 'Array Grid',
renderTo: 'grid-example',
viewConfig: {
listeners: {
viewready:function(){
var totalWidth = 0;
Ext.each(grid.columns, function(column, index) {
if (column.isHidden() == false)
totalWidth += column.width;
});
//console.log("Width: " + totalWidth);
grid.setWidth(totalWidth);
}
}
}
,listeners: {
columnresize: function(){
grid.viewConfig.listeners.viewready();
},
columnhide: function(){
grid.viewConfig.listeners.viewready();
},
columnshow: function(){
grid.viewConfig.listeners.viewready();
}
}
});
});
Perhaps you are loking for autoScroll? Don't know what kind of behaviour you want from the question.
The question remains, do you want the grid to have scrollbars, or do you want the div to have scrollbars, or do you want the browser to have scrollbars?
The div is a block level element in HTML. It will automatically fill the browser's width, no more, no less in your example. ExtJS will then fill that div with the grid, making the grid as large as the browser's window, no more. Since you do not allow the grid to have scrollbars, the excess columns are cut off.
If you want the grid to have scrollbars, use autoScroll set to true.
If you want the div to scroll instead, set overflow: auto instead of visible on .myDiv. You would have to specify width on the grid itself too, and make it as wide as the width of the columns.
I recommend letting ExtJS handle the scrollbar as ExtJS can use more efficient rendering if you let it (only render columns and rows that are actually visible).
var Section1 = Titanium.UI.createView({
top:0,
height: 'auto',
});
var Section2 = Titanium.UI.createView({
top:0,
height: 'auto',
});
I have two views and these two views has some buttons and TextFields which comes dyanmically. How can i control the Section 2 that it does not over lap the Section 1 View when its height gets increased.
I don't know if there's a better way, but I had a similar issue recently, which I tentatively solved like so
var Section1 = Titanium.UI.createView({
top:0,
height: 'auto',
});
// Add other views to Section1
var Section2 = Titanium.UI.createView({
top: Section1.toImage().height,
height: 'auto',
});
I think in your case the height will only be accurate after you've added your other views and objects to it.
If you are adding your views directly to the Ti.UI.currentWindow then you can just set layout of the Ti.UI.currentWindow to 'vertical' and the heights will automatically adjust
Ti.UI.currentWindow.layout = 'vertical';
Ti.UI.createView({
layout : 'vertical',
height : Ti.UI.SIZE
});