Page 1 of 3

Passing ListView Data to Detail Page

Posted: Sun Sep 29, 2013 3:31 pm
by Vance Sng

Hi

I have a listview populated with data from a local SQLite database. On clicking an item, I would like to pass the item id to a detail page which pulls the details from the same SQLite database. How do I do this? Is there a sample to demonstrate?

Thanks and regards
Vance


Passing ListView Data to Detail Page

Posted: Sun Sep 29, 2013 3:57 pm
by maxkatz

You can use local storage to save the id and then use it on another page. This examples shows how to do it: http://docs.appery.io/tutorials/build...


Passing ListView Data to Detail Page

Posted: Thu Oct 03, 2013 12:37 pm
by Vance Sng

Thank you Max. I'll give it a try.


Passing ListView Data to Detail Page

Posted: Sat Oct 05, 2013 2:16 pm
by Vance Sng

Hi Max

I managed to pass the id using local storage. Now encounter a new but related situation,

Project List page - I have a listview of projects, populated with data in SQLite using generic service. Clicking on any one project will link to a project detail page. This worked.

Project Details page - On this page should be a listview of stores belonging to the project selected on the above page. When I approached this page with a similar generic service and javascript implementation (but pointing to different SQLite DB and tables), the data couldn't be listed. Strangely, the Project listview also stopped rendering (nothing change on this page) when it was working earlier.

Below is the implementation approach taken for the Project Details page. Adapted from that taken for the Project List page.

Please advise what I did wrong. Wasted many hours. Thanks in advance.

var db = window.openDatabase("SQLiteStoreList", "", "SQLiteStoreList", 1024 * 1000);

$t.GetStoreListJS = $t.createClass(null,
{
init: function(requestOptions)
{
this.__requestOptions = $.extend({}, requestOptions);
},

Code: Select all

 process: function(settings)  

{
ProjectID = localStorage.getItem("ProjectList_ID");

Code: Select all

     if (this.__requestOptions.echo)  

{
settings.success(this.__requestOptions.echo);
} else
{
var ourFinalArray = [];

Code: Select all

         db.transaction(function(tx) { tx.executeSql('SELECT * FROM "' + ProjectID + '"' , [], function(tx, results)  
            {  
             var len = results.rows.length, 
             i; 
             if (len == 0)  
  {   
                     console.log("No record"); 
                 }  
             else  
                 { 
                     for (i = 0; i < len; i++) {  
                     ourFinalArray.push(results.rows.item(i));                     }       
                     settings.success(JSON.stringify(ourFinalArray));             
             } 
             settings.complete('success');             
         }); }); 
     }; 

}
});


Passing ListView Data to Detail Page

Posted: Sat Oct 05, 2013 6:44 pm
by maxkatz

Are you getting the data, it's just not being displayed? Let's first check that you are getting the data from the database.


Passing ListView Data to Detail Page

Posted: Sun Oct 06, 2013 2:10 am
by Vance Sng

Hi Max

Thanks for replying over the weekends.

Project List page - I could get the project data (from Appery or SQLite DB) before I ran test for the Project Detail page. After the test, data from SQLite DB stopped displaying (even when I didn't make any changes to the page). Only data from Appery DB display.

Deleting and re-doing the Project List generic service and javascript implementation would get the SQLite data displayed again.

Project Details page - I could get the store data from Appery but not SQLite DB, though I could see the SQLite DB in F12 Chrome.

I didn't see any related bug in the Chrome console.

To clarify, the Project (to obtain overall project info) and Store (to obtain stores belonging to the selected) are separate SQLite DBs.

Many thanks in advance
Vance


Passing ListView Data to Detail Page

Posted: Sun Oct 06, 2013 11:36 pm
by maxkatz

When you got to Project Details page -- is your generic service being invoked?


Passing ListView Data to Detail Page

Posted: Mon Oct 07, 2013 1:52 am
by Vance Sng

Yes, I invoked the generic service and tested.


Passing ListView Data to Detail Page

Posted: Mon Oct 07, 2013 4:55 am
by maxkatz

And the service returns the correct data?


Passing ListView Data to Detail Page

Posted: Mon Oct 07, 2013 5:03 am
by Vance Sng

No, the detail page did not return any store data.