This is a migrated thread and some comments may be shown as answers.

Select From JSON

5 Answers 46 Views
General Discussion
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Tom
Top achievements
Rank 1
Tom asked on 04 Mar 2015, 03:19 AM
Hi All - complete noob to this world so please forgive my ignorance.

I set up Cloud Data and add four rows of data to two types.  I have successfully (albeit rudimentary) coded some javascript to pull the data and build <select> form element - issue is I only see 2 rows returned and not 4 as I would have expected - what I am I doing worng?  Thanks ~T

My JS
var count = 0;
var el = new Everlive({
         apiKey: '**************************',
         scheme: 'https'
});
var casinos = el.data('casinos');
        casinos.get()
            .then(function (data) {
                BindDataToSelectCasinos(data);
            }, function (err) {
                alert(err.message);
            });
 
        function BindDataToSelectCasinos(e) {
            var jsonStr = JSON.stringify(e);
            var json = JSON.parse(jsonStr)
            $('#casinos');
            $.each(e, function () {
                $('#casinos').append(
                    $("<option></option>").text(json.result[count].CasinoName).val(json.result[count].Id)
                );
                count = count + 1;
            });
            count = 0
        }

5 Answers, 1 is accepted

Sort by
0
Anton Dobrev
Telerik team
answered on 04 Mar 2015, 12:38 PM
Hi Tom,

Please, consider changing your code to:
$.each(json.result, function () {

Basically, the e parameter sent to the function contains the response received by the SDK which is in format:
{
  "count": 101,
  "result": [{...}, {...}]
}

If the iterator function uses as argument just e, it will always iterate to 2 and stop. That is why you need to pass the array with the data items.

Let me know if you have further questions.

Regards,
Anton Dobrev
Telerik
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
0
Tom
Top achievements
Rank 1
answered on 04 Mar 2015, 12:56 PM
Thanks Anton!  I knew it was something simple.
0
Anton Dobrev
Telerik team
answered on 05 Mar 2015, 01:26 PM
Hi Tom,

Glad to hear that this is working on your side.

Let me know if you have questions.

Regards,
Anton Dobrev
Telerik
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
0
Tom
Top achievements
Rank 1
answered on 05 Mar 2015, 02:49 PM
Hey Anton - Quick question - I am struggling with storing user data entered via a form into a Cloud Data table - is there a simple example that shows how this should be done?

T
0
Anton Dobrev
Telerik team
answered on 06 Mar 2015, 11:47 AM
Hello Tom,

Generally, you need to construct and pass a data model to the methods of the SDK and it will do the rest.

We do not have an example for this but I am sure that the JS SDK documentation and the sample app which you can clone in AppBuilder from here will be helpful.

Also, if you could share the code that is causing the impediment, we would be happy to help you.

Best regards,
Anton Dobrev
Telerik
 

Visit the Telerik Verified Plugins Marketplace and get the custom Cordova plugin you need, already tweaked to work seamlessly with AppBuilder.

 
Tags
General Discussion
Asked by
Tom
Top achievements
Rank 1
Answers by
Anton Dobrev
Telerik team
Tom
Top achievements
Rank 1
Share this question
or