Page 2 of 2

How can I use value from input field as basis for a query?

Posted: Sun May 03, 2015 2:59 am
by Bruce Stuart

on having a new blank page show up - you would navigate to the control, on the virtual click event - you would click - Navigate to - and then specify the page you created (that for now is blank I assume).

On the other topic - More assuming I guess - the UI you have presented contains 'some of the db fields' and when clicking on Windy - you want to show more.

I would implement this as put a control on the page that's meant to show the additional data. Turn off the 'visible' checkbox.

Go back to the mapper - and map the db field to the control in your success event.

On the button (windy) virtual click method I would add this code:

Appery('new new control name that you added goes here').show() ;

let me know if that's not what you had intended to ask - or i read your question wrong...

Best,

bruce


How can I use value from input field as basis for a query?

Posted: Sun May 03, 2015 10:08 am
by Dennis Nygaard Nielsen

Hi Bruce

Not sure it is exactly what I want. If you look at what I have so far:
http://appery.io/app/mobile-frame?src...

type in 15 km/h and 200 ha/l

I would like to be able to click "windy" or whatever condition shows up (I dont have all my data in the DB) then open a new page like it does now. Then show all the data from the previous query: var sreturn = '{"$and": [{"filter_high":{"$lte":' + input.text() + ' }},{"filter_low": {"$gte":' + input.text() + ' }}]}';

But only the ones with "windy" as condition since this was the category I clicked.

There must be some sort of child function I can use i guess?

My old (messy) code looked something like this:

Code: Select all

var db = Ti.Database.install('../products_en.sqlite','products'); 
var rows = db.execute('SELECT DISTINCT category FROM products WHERE filter_low = ? ORDER BY catno', lmin, lmin ); 

var dataArray = [];

// create the array

while (rows.isValidRow())
{
dataArray.push({title:'' + rows.fieldByName('category') + '', hasChild:true, path:'../products/products.js'});
rows.next();
};

Code: Select all

 rows.close(); 
 db.close(); 

// set the array to the tableView
tableview.setData(dataArray);
};

// create table view
var tableview = Ti.UI.createTableView({
//backgroundColor:'white',
//color:'black'
});

tableview.addEventListener('click', function(e)
{
if (e.rowData.path)
{
var win = Ti.UI.createWindow({
url:e.rowData.path,
title:e.rowData.title,
lmin:lmin,
pressure:pressure,
volumeread:volumeread,
barColor:'black'

});

var prodCat = e.rowData.title;
win.prodCat = prodCat;

Ti.UI.currentTab.open(win);

}
});

// add the tableView to the current window
view.add(tableview);


How can I use value from input field as basis for a query?

Posted: Sun May 03, 2015 3:55 pm
by Dennis Nygaard Nielsen

Think I am going to take another take on this using this guide instead: https://www.youtube.com/watch?v=Kehn1...

Thank you so much for your help