New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How should data in promise be formatted? #35
Comments
If you loading data by pages from server ( {
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/ |
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') |
what I am trying to do is an asynchronous call and returning the data in a promise. |
Please, provide entire grid config. Maybe you could modify my fiddle to demonstrate the problem. |
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,
|
Send me the link to the updated fiddle then. |
Here is the link: http://jsfiddle.net/6690vqaz/1/
|
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. |
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) Here is the code that I used to create the object: function getRecords() {
Thanks,
|
You are right, the format of objects in array is incorrect. You provide them as strings, but elements of |
Thanks so much for your help. It is now working for me.
|
You are always welcome! |
I am trying to use loadData with a promise. However, it does not load theater. I return 1 record for testing and the grid ends up showing 12 pages of blank data. Perhaps I am formatting the data incorrectly? The format that I am returning in the promise is:
{ data: [{"AccountName":"MyAccount","ContactNumber":"111-111-7890","AccountNumber":"123456789","UserName":"JaneDoe"}], itemsCount: [1] }
Is this not correct?
The text was updated successfully, but these errors were encountered: