optikalefx / OpenJS-Grid

OpenJS Grid is the easiest jQuery Grid ever. With very little work you can have a data grid that can do everything from sorting and searching to complex database queries. Best of all, its open source. So you can learn how it's all done.
http://square-bracket.com/openjs
MIT License
96 stars 46 forks source link

refresh #12

Closed tokick4 closed 11 years ago

tokick4 commented 11 years ago

I was wondering if you have any methods that allows for the grid to auto-refresh or is there a way to set it up. I am pulling data from MySQL using AJAX and I want to set a time to refresh the grid with new data.
Thanks for the help so far.

optikalefx commented 11 years ago

When do you wanna refresh it? If its on an interval you can simply do

$(".grid").on("loadComplete",function() {
    var self = this;
    setInterval(function() {
         $(self).grid("load");
    },5000);
});
ioconnor commented 11 years ago

Be cool if the changes were pushed instead of pulled.

optikalefx commented 11 years ago

For that - You need my other tool RealTime. http://connectai.com/realtime it would allow php or js to trigger changes to be pushed to the grid. Which wouldn't even need a refresh, you could just insert rows. Or refresh.

ioconnor commented 11 years ago

You need to hire a team of people to write tutorials using your fantastic tools.

tokick4 commented 11 years ago

I have a problem with this it is running but then it multiples the call and after the 4th time it hangs the load logo and then hangs up and calls about 83 events.
sorry I cannot get the code to go in correctly so I had to take a screen shot. ScreenHunter_01 Feb 12 15 15

optikalefx commented 11 years ago

oh, right. Yes. Because it calls grid load over and over again, then calls itself. Take the setInterval OUT of the loadComplete.

So inside just do $grid.grid("load"); instead of $(self)

optikalefx commented 11 years ago

@iconner ha, thanks. Yea I wanna spend some quality time with RealTime. I'm using it for a lot of my clients now, hard to finish the consumer version.

tokick4 commented 11 years ago

if the setInterval is removed how doe it fire off every 5sec.

optikalefx commented 11 years ago

Remove that whole piece from the loadComplete. So after all the grid call, you will just do

setInterval(function() {
     $grid.grid("load");
},5000);
tokick4 commented 11 years ago

thanks i just figured it out with trial and error. You are awesome thanks for the help and this grid after working with it I am starting to like it and getting use to it after messing with it all day.

Thanks again

optikalefx commented 11 years ago

My pleasure. Thanks for using it!

tokick4 commented 11 years ago

question how do you add code to this what is the comments before and after to insert code

optikalefx commented 11 years ago

4 spaces before you start type, and then a line break before and after

this is 4 spaces

Here is a link to all the syntax you can do http://github.github.com/github-flavored-markdown/