NimbleKit - fast iOS app development

SQLite bindToDataBase JS parameter

Ask questions and share your skills here

SQLite bindToDataBase JS parameter

Postby sash1024 » Tue Jan 31, 2012 6:09 pm

Hi guys!

bindToDataBase question:

database.executeSQL("CREATE TABLE food(pk INTEGER PRIMARY KEY, category VARCHAR(25), title VARCHAR(25), subtitle VARCHAR(25), image VARCHAR(255), right_image VARCHAR(255), js VARCHAR(255), description TEXT)");

database.executeSQL("INSERT INTO food(category,title,subtitle,image,right_image,js,description) VALUES('MEAT','Rabbit','','','','foodDetails()','Rabbit is very good')");
database.executeSQL("INSERT INTO food(category,title,subtitle,image,right_image,js,description) VALUES('MEAT','Beef','','','','foodDetails()','Steak is very good')");
...

table works great, with sections at the right place, but I need to open a detail.html to show the food description, so the next step to do would be:

function foodDetails (pk) {
var navController = new NKNavigationController();
navController.gotoPage("detail.html?myVar="+pk);
}

where "pk" should be the index of the database, so in the detail.html I can get all the data from the table and show the full description.

Any ideas?
sash1024
 
Posts: 23
Joined: Sat Jan 21, 2012 12:58 pm

Re: SQLite bindToDataBase JS parameter

Postby rouillip » Wed Feb 01, 2012 10:40 am

Not sure, but just to try to help you !!
I think the navigationController should be initiated outside of the function, and just the link gotoPage() inside of the function.
Personaly in this case i use NKMoveToPageAnimated, with a return button on the detail.html page.

If i am wrong, forgot my message !
NimbleKit Registered user U885740601
User avatar
rouillip
NimbleKit Expert
 
Posts: 267
Joined: Wed Jan 13, 2010 9:38 am
Location: Paris 75018 (France)

Re: SQLite bindToDataBase JS parameter

Postby sash1024 » Wed Feb 01, 2012 12:28 pm

Hey thanks! Great trick for the navigation, I will try that.

However, the main issue here, for what I am trying to find a solution is:

I have the table created from the database with its items, it is fine. Groups work also.
When I click one row, it will open the item description page. It works. But I need to fill in the data.

Now, I need a way to pass the pk value to the page, in order to get the data related to that row. With a standard TableView method construction, it is not a problem, but with bindToDataBase can't find a way to pass the callback value to the table records.

Maybe there is an easy way I just overlooked.

Why I want to do it with bindToDataBase? Because I want to take advantage of its layout for the groups.

Maybe the right question is this: is there a way with bindToDataBase to pass to the table record callback with a dynamic value, such as in the usual NKTableView method? i.e.

food.callback = "foodDetails ("+pk+")";

maybe I can pass to the database the "foodDetails (1)" value for the js field, "foodDetails (2)" and so on, for example.

database.executeSQL("INSERT INTO food(category,title,subtitle,image,right_image,js,description) VALUES('MEAT','Beef','','','','foodDetails(2)','Steak is very good')");

or
maybe I can get the pk value out of the row, somehow. I know how to do it with the normal record construction but not with bindToDataBase.

What do you suggest? I am a little bit lost... I try so many different solutions with no success, maybe I am just confused.
sash1024
 
Posts: 23
Joined: Sat Jan 21, 2012 12:58 pm

Re: SQLite bindToDataBase JS parameter

Postby rouillip » Wed Feb 01, 2012 1:57 pm

I have no experience whith bindtodatabase

What i use to pass parameter from page to page is NKSettings (works as can do a cookies)

Have :
setValueForKey(value,key) on one page (can be in a onPageHidden() function) to store the value
And
getValueForKey(value) on and other page to get the value
For me it is a safe way to transmit parameters
NimbleKit Registered user U885740601
User avatar
rouillip
NimbleKit Expert
 
Posts: 267
Joined: Wed Jan 13, 2010 9:38 am
Location: Paris 75018 (France)

Re: SQLite bindToDataBase JS parameter

Postby gmaendel » Thu Jul 05, 2012 5:31 am

did you ever get this working? what solution did you use?
gmaendel
 
Posts: 17
Joined: Fri Mar 02, 2012 5:38 pm

Re: SQLite bindToDataBase JS parameter

Postby rouillip » Thu Jul 05, 2012 8:58 am

Yes, its works well
NimbleKit Registered user U885740601
User avatar
rouillip
NimbleKit Expert
 
Posts: 267
Joined: Wed Jan 13, 2010 9:38 am
Location: Paris 75018 (France)

Re: SQLite bindToDataBase JS parameter

Postby gmaendel » Thu Jul 05, 2012 3:08 pm

Actually I was asking sasha1024 about getting the bindToDatabase to return what row was pressed. I know how passing variables works as I've used it before. But what does bindToDatabase return when you press a row? Does it return pk or what?
gmaendel
 
Posts: 17
Joined: Fri Mar 02, 2012 5:38 pm

Re: SQLite bindToDataBase JS parameter

Postby rouillip » Thu Jul 05, 2012 3:19 pm

sorry; i never used bindToDataBase
NimbleKit Registered user U885740601
User avatar
rouillip
NimbleKit Expert
 
Posts: 267
Joined: Wed Jan 13, 2010 9:38 am
Location: Paris 75018 (France)


Return to How To...

Who is online

Users browsing this forum: Google [Bot] and 0 guests