Git Product home page Git Product logo

Comments (12)

tabalinas avatar tabalinas commented on July 21, 2024 1

If you loading data by pages from server (pageLoading: true), then you should return data in format

{
    data: [items],
    itemsCount: amountOfItems
}

// for your case
{
    data: [{"AccountName":"MyAccount","ContactNumber":"111-111-7890","AccountNumber":"123456789","UserName":"JaneDoe"}],
    itemsCount: 1 // without array
}

In most cases it's enough to load all data (usually it works faster for not huge amount of data). In this case just return the array of items.

See following fiddle with two examples http://jsfiddle.net/tabalinas/6690vqaz/

from jsgrid.

jhammer2 avatar jhammer2 commented on July 21, 2024

Thanks for the reply. I tried your suggestion, however it just keeps showing the please wait. When looking in the browser console I see the following error. I am also doing a console.logo on my promise data to see that it is formatted correctly. Any suggestions on how to resolve this?

{ data: [{"AccountName":"MySuperDuperAccount","ContactNumber":"123-456-7890","AccountNumber":"123456789","UserName":"RickyBobby","Password":"FightingChicken","DueDate":"2015-05-20","MonthlyPayment":"100.00"}], itemsCount: 1 }

jsgrid.core.js:492 TypeError: undefined is not an object (evaluating 'this.data.length')

from jsgrid.

jhammer2 avatar jhammer2 commented on July 21, 2024

what I am trying to do is an asynchronous call and returning the data in a promise.

from jsgrid.

tabalinas avatar tabalinas commented on July 21, 2024

Please, provide entire grid config. Maybe you could modify my fiddle to demonstrate the problem.

from jsgrid.

jhammer2 avatar jhammer2 commented on July 21, 2024

I have updated your fiddle. However, you will not see the error due to the DB not existing, but you are able to see the controller code that I am using. Perhaps I am doing something incorrectly there?

Thanks,
John

On May 29, 2015, at 12:56 AM, Artem Tabalin [email protected] wrote:

Please, provide entire grid config. Maybe you could modify my fiddle to demonstrate the problem.


Reply to this email directly or view it on GitHub #35 (comment).

from jsgrid.

tabalinas avatar tabalinas commented on July 21, 2024

Send me the link to the updated fiddle then.

from jsgrid.

jhammer2 avatar jhammer2 commented on July 21, 2024

Here is the link:

http://jsfiddle.net/6690vqaz/1/

On May 29, 2015, at 1:20 PM, Artem Tabalin [email protected] wrote:

Send me the link to the updated fiddle than


Reply to this email directly or view it on GitHub #35 (comment).

from jsgrid.

tabalinas avatar tabalinas commented on July 21, 2024

The promise should be resolved an actual JS object, not a string representation

feeds = '{ data: ['+feeds+'], itemsCount: '+len+' }';
def.resolve(feeds); // feeds is a string, but should be an object

Should be

feeds = {
    data: [items] // provide array, not a string here too
    itemsCount: len
};
def.resolve(feeds);

Hope it will help.

from jsgrid.

jhammer2 avatar jhammer2 commented on July 21, 2024

That is very helpful. I am now getting the screen to come up, however the cells are blank. When looking in the browser console I do the javascript object. can you tell if I am loading the object incorrectly? I am putting the array in, but perhaps the format is incorrect?

[Log] Object (roa.js, line 57)
data: Array[1]
0: "{"AccountName":"MySuperDuperAccount","ContactNumber":"123-456-7890"}"
length: 1
proto: Array[0]
itemsCount: 1
proto: Object

Here is the code that I used to create the object:

function getRecords() {
var feeds = "";
var def = $.Deferred();
var db = window.openDatabase("Database", "1.0", "MyDB", 200000);

                                        db.transaction(function(tx) {
                                        var db = window.openDatabase("Database", "1.0", "MyDB", 200000);

                     tx.executeSql("SELECT AccountName,ContactNumber FROM BILL_TABLE", [], function(tx, results) {

                                                                var len = results.rows.length;
                                                                var feedarray = [];

                                                                for (var i = 0; i <=len-1; i++) {

                                var len = results.rows.length;
                                                                    var roaObj =results.rows.item(0);
                                                                    var jsonString=JSON.stringify(roaObj);

                                                                    feedarray.push(jsonString);
                                                                }
                                console.log(feedarray);

                                                                  feeds = {
                                                                            data: feedarray, // provide array, not a string here too
                                                                            itemsCount: len
                                                                    };
                                                                    console.log(feeds);
                                                                  def.resolve(feeds);
                                                            });
                                        });
                                return def.promise();
                        }

Thanks,
John

On May 29, 2015, at 3:42 PM, Artem Tabalin [email protected] wrote:

feeds = {
data: [items] // provide array, not a string here too
itemsCount: len
};
def.resolve(feeds);

from jsgrid.

tabalinas avatar tabalinas commented on July 21, 2024

You are right, the format of objects in array is incorrect. You provide them as strings, but elements of data array should be also js objects. You can see the problem in console, where object is printed in quotes.

from jsgrid.

jhammer2 avatar jhammer2 commented on July 21, 2024

Thanks so much for your help. It is now working for me.

On May 31, 2015, at 5:27 PM, Artem Tabalin [email protected] wrote:

You are right, the format of objects in array is incorrect. You provide them as strings, but elements of data array should be also js objects. You can see the problem in console, where object is printed in quotes.


Reply to this email directly or view it on GitHub #35 (comment).

from jsgrid.

tabalinas avatar tabalinas commented on July 21, 2024

You are always welcome!

from jsgrid.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.