- This topic has 17 replies, 3 voices, and was last updated 9 years, 11 months ago by RogelioChavarria.
-
AuthorPosts
-
RogelioChavarriaParticipantHi, i have hours trying to populate a list from a database table, my table has 19 colums and i need to know how to populate a menú from a data un a database column, next that the menú send to other page that shows all the information… please help me i have 3 months with the licence and im still cant do this.
thanks.
Code_AMemberHave you looked at the webSQL custom list example in the how-to section? Maybe it will be useful to you.
RogelioChavarriaParticipantThanks, it works for me, so now i like to know how to add dynamic images?
my db rows are for example: name, phone, picture (values: peter, 8112343434, peter.jpg)
how can i add the file peter.jpg to the project and how i can called from mobione?
thanks again!
Code_AMemberMaybe this post will help: viewtopic.php?f=8&t=7099
RogelioChavarriaParticipantThanks, ok, so i will add the pictures to the proyect as aditional files, but how can i load the pictures in the mobione design center?
what kind of container i need to use?
RogelioChavarriaParticipantmay be a html code… do you have something usefull?
support-octavioMemberHi rogeliochavarria,
If you are using as template the webSQL custom list example, these are the things that you will need to modify:
1) Add an image widget to your item.mobi file
2) Bind the data for your image attr adding it to every item that is used to represent your db. (list-db.js line ~108).var newItem = {
‘id’: results.rows.item(i).id,
‘image’ : results.rows.item(i).imageColName, <—
‘item’: results.rows.item(i).item};
items.push(newItem);3) Make the image widget update with the image of the item requested when item.mobi screen is visited. Add next code to the updateItemScreen in the list-db.js
$('[id$=image1]').attr("src",selectedItem.image);
Note that image1 is the name of the image widget you added to item.mobi screen.
Hope this is helpful.
RogelioChavarriaParticipantThanks!!! It works, i have one more question, my database is over mysql and i have a cvs file, do you know if there is a tool to import-convert a cvs content file to the .js file?
Thanks again.
support-octavioMemberHi rogeliochavarria,
I did a little research and found this library that might help you: jquery-csv 0.7 (Beta)
Before you integrate it in a mobione app you should make sure that it works in your target platform(s) as this is a 3rd party component and your mileage may vary.
RogelioChavarriaParticipantHi again, im almost done but now i need to use a combo box to filter the data from my local database, im usign “list-db-example”, im trying to use a combobox to filter the data by x or y… can you help me with this issue?
in the list-db.mobi i need a custom list filtered by the selected values on the combobox, obviusly these values come from a column in my local database.
example:
DATABASE
NAME, LASTNAME, PHONE, CITYCOMBOBOX VALUES
BEAVERTON
HILLSBORO
PORTLANDthen the list will show only the data from the selected values on the combobox.
Thanks again for your time and help.
Code_AMemberThis would be handled in your database SQL statement. Just pass the filter value when querying the database.
For example,
SELECT Name, LastName, Phone, City FROM Users WHERE City = 'Portland';
Here is how you can get the selected value from the combobox, assuming its name is ‘cboCity’:
var city = $('select[name="cboCity"]').val();
If you need specific coding help within M1, then please post the code you are using to make the call to your DB for data.
RogelioChavarriaParticipantOk, this is my list-db.js… the idea is that the combobox filters the data by “ESPECIE” and delete the checkbox
Thanks for all your help. Octavio if you speak spanish will be better for me.Attachments:
You must be logged in to view attached files.
Code_AMemberIs your question related to javascript and coding of the m1 widgets (i.e., getting values from the combobox and dropdown), or is related to construction of the SQL statement to query the database (i.e., return only the filtered data)?
RogelioChavarriaParticipantBoth, i need like to use the combobox to get values (java) and have only the filtered data in the list (SQL+JAVA). Can you halp me with this issue?
at this moment i can use the statment WHERE in SQL to filter the data, but i dont know how to tell SQL from M1 what data i want. How comunícate combobox with sql and then sql with the list.
Thanks!
Code_AMemberTry adding a select function similar to the one below into your code.
(NOTE: this code has not been tested…it is meant to be used as an example).
This example assumes your combobox name is cboEspecie and that you are pulling all the fields of data from the “items” table.
/** * Select from ITEMS table */ function selectItems() { console.log('select: ' + $('select[name="cboEspecie"]').val();); db.transaction( function(tx) { tx.executeSql('SELECT * FROM items WHERE ID = ' + $('select[name="cboEspecie"]').val();); phoneui.back(); }); }
If you need your results to match multiple selections, than you can concatenate your WHERE clause to include all selected items by just placing the ‘AND’ operator between the values.
For example:
... WHERE Esepcie = 'Portland' AND 'Hillsboro';
(You could setup a variable to hold the “WHERE” clause and then just add the variable to the end of the SQL statement).
Here is how you can get a value from a combobox:
$('select[name="combobox1"]').val()
Here is how you can tell if a checkbox is checked:
$('#form1-checkbox1 > input').is(':checked')
Here is the MobiOne Widget Reference.
Here is the W3 Schools SQL TutorialHope this helps get you started!
-
AuthorPosts