Vance Sng
Posts: 0
Joined: Sun Sep 29, 2013 3:31 pm

Passing ListView Data to Detail Page

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

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Passing ListView Data to Detail Page

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...

Vance Sng
Posts: 0
Joined: Sun Sep 29, 2013 3:31 pm

Passing ListView Data to Detail Page

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

Vance Sng
Posts: 0
Joined: Sun Sep 29, 2013 3:31 pm

Passing ListView Data to Detail Page

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');             
         }); }); 
     }; 

}
});

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Passing ListView Data to Detail Page

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

Vance Sng
Posts: 0
Joined: Sun Sep 29, 2013 3:31 pm

Passing ListView Data to Detail Page

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

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Passing ListView Data to Detail Page

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

Vance Sng
Posts: 0
Joined: Sun Sep 29, 2013 3:31 pm

Passing ListView Data to Detail Page

Yes, I invoked the generic service and tested.

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

Passing ListView Data to Detail Page

And the service returns the correct data?

Vance Sng
Posts: 0
Joined: Sun Sep 29, 2013 3:31 pm

Passing ListView Data to Detail Page

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

Return to “Issues”