Hi Paramvir,
I am new to the asynchronous nature of javascript and am having difficulty making the grid wait for my data before displaying. Here are the bullet points for this scenario. I'm hoping I can get away without providing a lot of code, but I will do whatever is needed to get this particular issue resolved.
- The app is being created with node.js and Electron.
- I have one function that fetches the data from an SQLite database residing on the local hard drive the app is on.
- I have another function that has all the code to display the grid.
So the code looks something like this:
function getGridData(callback) {
<--the code to get the grid data for the dataModel-->
callback(gridData);
}
function displayGrid (gridData){
<--the code to define and display the grid-->
var $grid = $("#main_grid").pqGrid(obj);
}
getGridData(displayGrid);
When i run the script, a blank grid with no gridData is diplayed. If I click any button on the grid toolbar that gets the instance of the grid, all of the data is then displayed so I know the callback executed and passed the data to the displayGrid function. Also if I put a short timeout around the
var $grid = $("#main_grid").pqGrid(obj);
statement, the grid is initialize properly with all gridData so again, I know the callback is working and passing the gridData, but the displayGrid is displaying without waiting for the dataModel data. This is driving me crazy so if you can help me with this, I would be very appreciative.
Thanks,
Bawzee