Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Building off-line price lookup table?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Building off-line price lookup table?

    I am looking for the best and easiest way to do a price lookup table for both web and off-line mobile apps.

    I would like to do this using a JSON table, but it is pushing my programming limits.

    The SQL Table looks like this:

    type group drop x48 x54 x60 x66 x72 x78
    elite 1 36 306 322 337 352 368 381
    elite 1 48 336 354 371 389 406 421
    elite 1 60 369 388 406 426 446 461
    elite 1 72 398 419 441 462 483 502
    I would appreciate any thoughts that the group has on this.

    Thanks,

    Michael Carroll

    #2
    Re: Building off-line price lookup table?

    Hi Michael,

    I would say that lists will work the best, although if you have not used them yet, have patience. This will give you the offline feature and I have not done this myself but I believe you can programmatically synchronize the data triggered depending if there is an internet connection or some other criteria. Alternately you could have 2 lists one for mobile and one for the web.
    Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

    Comment


      #3
      Re: Building off-line price lookup table?

      Frank,

      I have been using lists a lot, but I was not aware that I could query the list using javascript.

      I have the following fields:

      [ Width ] [ Height ] then the field that returns a price from the table I listed above.

      In MySQL I can write a Stored Procedure and then a Xbasic function to get this value to return. Here is my code to do this:

      Code:
      CREATE DEFINER=`root`@`localhost` PROCEDURE `elite_price_LkUp`(
      	IN xdrop int,  -- the drop
      	IN xwidth int, -- the width
      	IN fgroup int
      	)
      begin
      -- case statement to get the value
      
      	CASE xwidth
      		When (xwidth >= 39) and (xwidth <= 48)
      	THEN set @fname = "x48";
      		When (xwidth >= 48) and (xwidth <= 54)
      	THEN set @fname = "x54";
      		When (xwidth >= 54) and (xwidth <= 60)
      	THEN set @fname = "x60";
      		When (xwidth >= 60) and (xwidth <= 66)
      	THEN set @fname = "x66";
      		When (xwidth >= 66) and (xwidth <= 72)
      	THEN set @fname = "x72";
      		When (xwidth >= 72) and (xwidth <= 78)
      	THEN set @fname = "x78";
      	ELSE set @fname = 0;
      END CASE;
      
      -- prepare the statement
      set @sql = concat('Select ', @fName,
       ' FROM cp1.ps_elite_pricing  WHERE h_drop = ',
      xdrop,' AND  fabgroup =', fgroup);
      
      PREPARE stmt FROM @sql;
        EXECUTE stmt;
        DEALLOCATE PREPARE stmt;
      
      
      END
      I just feel like I am completely flying blind in being able to do this with a List Control.

      Comment


        #4
        Re: Building off-line price lookup table?

        Frank,

        Ok so I am able to do this with lists. Cool. So now my dilemma is that I have 8 different price grids. So I am experimenting with just having one price table, but I am having trouble doing a lookup. Withe single table I have 14 rows (0-13) and it is easy to specify a row number using {dialog.Object}.listGetValue('listLocalStorage',cn,rn); were cn is the column number and rn is the row number. However if I want to combine all 8 tables into to one the switch statement (case statement) would now be over a 100 lines parse out what row number.

        I using a function to return the fabric code + the vertical drop distance from the table.

        Fabric code:1
        Drop: 60

        or 160

        So I want to use the following so I can then lookup the values in this larger table.

        var lObj = {dialog.object}.getControl('listLocalStorage');
        var fn = lObj.getValue(rn).cn;

        were rn is the row number -- in this example it would be 160 and cn is the column number. Where I am getting stuck is that is that I am not sure how to structure the ".cn" part of the code. Oh yes -- it does not work as I have listed here.

        Thanks,

        For any help here.

        Michael Carroll

        Comment


          #5
          Re: Building off-line price lookup table?

          I wouldn't do this with lists... I think it's far more than you need.

          You don't need to display these price tables in any organized fashion... you just need to perform a price lookup. Is that right? Or do you need to see the price table?

          I would use localStorage.

          If you're connected, the get the table values from sql and then store it locally. Then always go after the localStorage when you need a price.

          Or, if you're connected, use sql. If not use localStorage.

          Comment


            #6
            Re: Building off-line price lookup table?

            Originally posted by Davidk View Post
            I wouldn't do this with lists... I think it's far more than you need.

            You don't need to display these price tables in any organized fashion... you just need to perform a price lookup. Is that right? Or do you need to see the price table?

            I would use localStorage.

            If you're connected, the get the table values from sql and then store it locally. Then always go after the localStorage when you need a price.

            Or, if you're connected, use sql. If not use localStorage.
            David,

            Yes I am using local storage. Interestingly though is that I can not tell the difference between the two.

            They seem to be exactly the same.

            Michael.

            Comment


              #7
              Re: Building off-line price lookup table?

              You're using localStorage via the List control. I guess the question is... do you need to see the prices... as in a List control... or just use them?

              localStorage is this excellent little bit of space you can use. It is a browser feature that the List control take advantage of.

              The List control is an intermediary... sitting in the middle between sql and localStorage.

              Comment


                #8
                Re: Building off-line price lookup table?

                I wouldn't do this with lists... I think it's far more than you need.

                You don't need to display these price tables in any organized fashion... you just need to perform a price lookup. Is that right? Or do you need to see the price table?

                I would use localStorage.

                If you're connected, the get the table values from sql and then store it locally. Then always go after the localStorage when you need a price.

                Or, if you're connected, use sql. If not use localStorage.
                You're using localStorage via the List control. I guess the question is... do you need to see the prices... as in a List control... or just use them?

                localStorage is this excellent little bit of space you can use. It is a browser feature that the List control take advantage of.

                The List control is an intermediary... sitting in the middle between sql and localStorage.
                David, can you elaborate a little? These two statements seem to be at odds. Please understand I am not trying to correct you, I am trying to better understand disconnected data as I see more and more how powerful it is, especially for my business. The only presentation that I saw was using lists to access the disconnected data. Or am I mistaken in thinking that 'disconnected data' and 'local storage' are synonymous?
                Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

                Comment


                  #9
                  Re: Building off-line price lookup table?

                  Frank, David will likely answer more fully, but Alpha's list controls are utilizing standard HTML5 local storage for the disconnected functionality. I haven't been in Firebug recently enough, but open one of your disconnected applications in Chrome, open the Developer tools window and go to Resources. There under localStorage you'll find the variables your lists have created. The basic syntax for this is quite simple:
                  Code:
                  localStorage.setItem('key','value');
                  var value = localStorage.getItem('key');
                  What the list controls are doing, you'll find, is doing this exact thing except that the 'value' is a long, time-stamped, JSON string with all the values you can access via the list. When you make a change in the list control, it "simply" does a localStorage.setItem('key','updatedString');

                  You can add additional key-value localStorage pairs outside the list control functionality. For example, I'm working on a component that I set a variable for the User's ID in a Settings page, and then the lists can be filtered by that User's ID. So I'm storing and retrieving the User's ID in localStorage so that they don't have to change the settings each time and it will remember who the user is. I'm using simple key-value pairs.

                  What David's suggesting Michael do is create these strings himself in JSON and store them via javascript without creating a list control to handle the localStorage string creation. I'm likely to explore that this week as I fully get the concept of JSON but haven't figured out the syntax well enough to just code it easily--eager to see what David has to suggest on the subject.

                  Comment


                    #10
                    Re: Building off-line price lookup table?

                    Thanks Chris, that makes a lot of sense. I am eager to make full use of these new features.
                    Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

                    Comment


                      #11
                      Re: Building off-line price lookup table?

                      localStorage is a browser feature... not an Alpha feature.

                      localStorage uses name/value pairs to store data... where "name" is a key to the value you want to store or retrieve.

                      To write to localStorage I like to use objects... you can get more done with them.

                      In this example I have a textbox control named 'dataLocalStorage' in a UX. A couple of buttons take care of the writing and reading.

                      Code:
                      var ls = supports_html5_storage();
                      if (ls){
                      	//create an object
                      	var dData = {};
                      	dData._data = {dialog.Object}.getValue('dataLocalStorage');
                      	var saveData = JSON.stringify(dData);
                      	localStorage.setItem("ls_test",saveData);
                      } else {
                      	alert("Local Storage not available");
                      }
                      To read localStorage...

                      Code:
                      var dObj = localStorage.getItem("ls_test");
                      if (dObj){
                      	//alert('we have data');
                      	var jsonData = JSON.parse(dObj);
                      	var dData = jsonData._data;
                      	{dialog.Object}.setValue('dataLocalStorage',dData);
                      } else {
                      	//alert('no ls data');
                      }


                      You'll need to figure out the best way to organize your pricing table for storing... but this reads and writes the data for you.

                      Comment


                        #12
                        Re: Building off-line price lookup table?

                        Thanks for clearing that up for me.
                        Win 10 64 Development, Win 7 64 WAS 11-1, 2, Win 10 64 AA-1,2, MySql, dbForge Studio The Best MySQL GUI Tool IMHO. http://www.devart.com/dbforge/mysql/studio/

                        Comment


                          #13
                          Re: Building off-line price lookup table?

                          What's really cool is that Alpha has integrated the noSQL databases. Plus, they're going after the device storage as well. This means we can do things very simply or, if needed, get more complex.

                          Comment


                            #14
                            Re: Building off-line price lookup table?

                            David,
                            I'm looking for help with this as well to do something similar to what you mentioned. I want to permanently store 2 text box entries so the user doesn't need to type them in each time. I also want to store a record entry if there is no connection on the device. I'm not having much luck getting it to work. I've watched Dion's video but that code didn't fit what I need. I really don't want to use a list since it's entry only. There are 10 fields to submit or alternately save to local storage. Do you have experience with that? I'm also having trouble finding the documentation on the functions related to disconnected...Thanks for any help.

                            Comment

                            Working...
                            X