Problem with php code before render

QuestionsProblem with php code before render
Akhlad asked 10 years ago

any php code before render is executed as many times as the render function is typed

for example I have some code

if ($_GET['do_some_stuff'] == 1){
// do some stuff;
}

………
………………….

g = new jqgrid();
$out = $g->render("list1");

What happens is the // do some stuff; part is executed 2 times

AND

if ($_GET['do_some_stuff'] == 1){
// do some stuff;
}

………
………………….

g1 = new jqgrid();
g2 = new jqgrid();
$ou1t = $g1->render("list1");
$out2 = $g2->render("list1");

What happens is the // do some stuff; part is executed 3 times

Huge issue

1 Answers
Abu Ghufran answered 10 years ago

The grid is loaded with 2 server calls.

1) load the columns of grid.
2) do an ajax call, to load data of grid.

When you have 2 grids, one call will load structure of both grids, and second+third ajax call for loading data of each grid.

For loading data, the ajax call have param 'grid_id' passed in $_GET, so if you want to run above code only once, you can put IF condition something like:

if (!isset($_GET["grid_id"]))
{
// once runnable code, when creating grid structure.
}

Your Answer

9 + 16 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?