Image Path in createTableViewRow in Titanium - image

I am creating table view in titanium. I got a problem here.
I am not getting image in leftImage of table row.
Here is the code:
var table1 = Titanium.UI.createTableView();
var section = Titanium.UI.createTableViewSection();
var row1 = Titanium.UI.createTableViewRow();
row1.leftImage : 'android/images/res/radio.jpg',
row1.title = "Nuts";
row1.color = "red";
section.add(row1);
data.push(section);
table1.setData(data);
I am getting the complete row but Image is not displaying. I tried it a lot. Waiting for your feedback.
Thanks in advance.

Doing it the way you provided I had some problem with too. Better try it with an imageview and position it. Something like this:
var image = Titanium.UI.createImageView({
url: Titanium.Filesystem.resourcesDirectory + 'android/images/res/radio.jpg',
left: 5
});
row1.add(image);
Make sure you use the root path for anything, especially in Android. You can do that with Titanium.Filesystem.resourcesDirectory which is the path to the resources directory.

there must be some issue with your image path. the code below works for me:
var win1 = Ti.UI.createWindow({
title:'home',
backgroundColor:'white'
});
var data = [];
var table1 = Titanium.UI.createTableView();
var section = Titanium.UI.createTableViewSection();
var row1 = Titanium.UI.createTableViewRow({
leftImage : 'images/KS_nav_ui.png',
title : "Nuts",
color : "red"
});
section.add(row1);
data.push(section);
table1.setData(data);
win1.add(table1);
win1.open();

Related

how to save a drawingpad image in nativescript

UPDATE
now its working, see the answer below (https://stackoverflow.com/a/43983621/2844901)
this is my getDrawing function, I need to save the signature from drawing to a file in file system, I've tried everything and I cant get the saveToFile demo in nativescript docs to get it work.
exports.getDrawing = function(args) {
var pad = frameModule.topmost().currentPage.getViewById("drawingPad");
// then access the 'drawing' property (Bitmap on Android) of the signaturepad
var img = frameModule.topmost().currentPage.getViewById("imagesignature");
pad.getDrawing().then(function(result){
img.src = result; // <-- this shows in an image label the drawing signature
########### this part should be save the file,but I don't get any error, and it doesn't save it to a file, when tried to dump "img" ############
var img2 = imageSource.fromAsset(result);
var folder = fs.knownFolders.documents();
var path = fs.path.join(folder.path, "Test.png");
var saved = img2.saveToFile(path, "png");
});
}
the problem was, the getDrawing() does not return a promise it returns an image so the correct code should be a NativeSource.
pad.getDrawing().then(function(result){
img.src = result;
console.log("1");
var img2 = imageSource.fromNativeSource(result);
var folder = fs.knownFolders.documents();
var path = fs.path.join(folder.path, "Test.png");
var saved = img2.saveToFile(path, "png");
console.log("saved: " + saved);
console.log("IMAGEN SRC.....");
});

Can I set windows sonsole width in Node.js?

Can I Set Windows Console width in Node.js?
process.stdout.columns =300;
process.stdout.rows = 300;
console.log(process.stdout.columns)
console.log(process.stdout.rows)
it doesn't work?
it's not very complicated.
var COORD=
refStruct({
X: ref.types.int16
,Y: ref.types.int16
})
//kernel32
this.kernel32 = new ffi.Library('kernel32', {
'SetConsoleScreenBufferSize': ['bool', ['int32', COORD]]
, 'GetStdHandle': ['int32', ['long']]
});
this.setConsoleBufferSize = function (colume,row) {
var handle = winapi.kernel32.GetStdHandle(-11);
var x = winapi.kernel32.SetConsoleScreenBufferSize(handle, new COORD({
X: colume
, Y: row
}));
};
Based on your comments and the documentation for process.stdout I would say that .columns and .rows are read only.
I've been looking for a while and it does not seem like there is any way to resize the console window from node.

How to get SVG element dimensions in FireFox?

In most browsers, the following would work.
window.onload = function(){
console.log( document.getElementById('svgElm').getBoundingClientRect().width );
};
Here is a demo. If you try it in Google Chrome, the console will output 200. However, FireFox returns 0.
I've ended up falling back to the parent dimensions if SVG properties cannot be returned. Here is a demo http://jsbin.com/uzoyik/1/edit.
The relavent code is:
svg.clientWidth || svg.parentNode.clientWidth
svg.clientHeight || svg.parentNode.clientHeight
I don't think "width" is a standard cross-browser property of the object returned by the getBoundingClientRect method. I typically do something like:
var box = el.getBoundingClientRect();
var width = box.right-box.left;
var height = box.bottom-box.top;
The solution I found for this was to use .getComputedStyle(). And since svg elements are not supported in old IE8- browsers, .getComputedStyle() is the way to give consistent results.
So I ended up using this function in my library:
var heightComponents = ['height', 'paddingTop', 'paddingBottom', 'borderTopWidth', 'borderBottomWidth'],
widthComponents = ['width', 'paddingLeft', 'paddingRight', 'borderLeftWidth', 'borderRightWidth'];
var svgCalculateSize = function (el) {
var gCS = window.getComputedStyle(el), // using gCS because IE8- has no support for svg anyway
bounds = {
width: 0,
height: 0
};
heightComponents.forEach(function (css) {
bounds.height += parseFloat(gCS[css]);
});
widthComponents.forEach(function (css) {
bounds.width += parseFloat(gCS[css]);
});
return bounds;
};
This Firefox bug was fixed in Firefox 33 which was released on 14 October 2014.
See bug 530985 for details.

AS3 URLRequest in for Loop problem

I read some data from a xml file, everything works great besides urls. I can't figure what's the problem with the "navigateURL" function or with the eventListener... on which square I click it opens the last url from the xml file
for(var i:Number = 0; i <= gamesInput.game.length() -1; i++)
{
var square:square_mc = new square_mc();
//xml values
var tGame_name:String = gamesInput.game.name.text()[i];//game name
var tGame_id:Number = gamesInput.children()[i].attributes()[2].toXMLString();//game id
var tGame_thumbnail:String = thumbPath + gamesInput.game.thumbnail.text()[i];//thumb path
var tGame_url:String = gamesInput.game.url.text()[i];//game url
addChild(square);
square.tgname_txt.text = tGame_name;
square.tgurl_txt.text = tGame_url;
//load & attach game thumb
var getThumb:URLRequest = new URLRequest(tGame_thumbnail);
var loadThumb:Loader = new Loader();
loadThumb.load(getThumb);
square.addChild(loadThumb);
//
square.y = squareY;
square.x = squareX;
squareX += square.width + 10;
square.buttonMode = true;
square.addEventListener(MouseEvent.CLICK, navigateURL);
}
function navigateURL(event:MouseEvent):void
{
var url:URLRequest = new URLRequest(tGame_url);
navigateToURL(url, "_blank");
trace(tGame_url);
}
Many thanks!
In navigateURL() you use tGame_url, but I think you'd rather use something like tgurl_txt.text which will be different for each square.
Looks like you're not attaching the event listener properly. Instead of this.addEventListener, attach it to the variable you created when creating new square_mc..... so:
square.addEventListener(MouseEvent.CLICK, navigateURL);
you should add the addEventListener on the Squares
mmm..still figuring how eventhandler function will ever get the correct tgame_url var.
What if you try this:
square.addEventListener(MouseEvent.CLICK, function navigateURL(event:MouseEvent):void
{
var url:URLRequest = new URLRequest(tGame_url);
navigateToURL(url, "_blank");
trace(tGame_url);
});
try tracing this:
function navigateURL(event:MouseEvent):void
{
var url:URLRequest = new URLRequest(tGame_url);
navigateToURL(url, "_blank");
//trace(tGame_url);
trace(event.currentTarget.tgurl_txt.text);
}
you should add the url to your square in the loop
square.theUrl = tGame_url;
in the event listener function you should be able to access it with
event.currentTarget.theUrl;

images and selectbox in jqgrid

hai i am very new to jquery and jqgrid..
i have implemented a grid...but i don't have any idea to display images in column from the corresponding database value...i tried a lot but failed ..can anybody help me..
regards
In the setup parameters add:
loadComplete: function() {
var ids = $("#list").getDataIDs();
for (var i = 0; i < ids.length; i++) {
var cl = ids[i];
be = "<img src='http://www.google.com/images/nav_logo6.png'>";
$("#list").setRowData(ids[i], { externalId: be })
}
},
In this example it will load the google logo. This sample goes over all the rows and adds the same item. You can change it do be more dynamic based on the current value of the cell etc.

Resources