Reload grid based on input fields

QuestionsReload grid based on input fields
Tom Fitz asked 7 years ago

Hi,
I am loading the grid in an I-frame using select command with date variables in the where clause. I then allow the user to change the date variables using inputs and submit the report using a submit button. But no matter what dates are entered, the grid shows the same records as the first run.

I've tried using trigger('reload Grid'); but it didn't change the rows either.

What can I do to make the grid refresh using input from the user?

Thanks,
Tom

6 Answers
Abu Ghufran answered 7 years ago

Check this FAQ item. If issue is not resolved then let me know.
Thanks.

Q) How to load grid based on $_POST data from other page?

The grid is loaded with 2 server calls.

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

Now, if you want to pass data from external form, it is available for step1. But not there in 2nd ajax call, as it is not posted.
Solution is to put the POST variable in session and use it from session for step2.

e.g.

if (!empty($_POST["personid"]))
{
$_SESSION["personid"] = $_POST["personid"];
}
$pid = $_SESSION["personid"];

and use `$pid` in your SQL.

Tomme answered 7 years ago

I have almost the same problem and because of my rookie-state i have not been able to find a solution.

I use the Link function to open another page with a argument, simliar to:
$col["link"] = "http://localhost/?id={id}";

But i fail to load any grid on the new page.

I'm afraid i dont know enough about sessions and how to lead data in the grid with an ajax call

A full example would be really helpful here…

Thanks,
Tomme

Abu Ghufran answered 7 years ago

To use this passed parameter on new page's grid, you need to set this $_GET in $grid["url"] so that it reflect in loading and editing of grid.

e.g.

URL for grid page (for ajax calls), defaults to REQUEST_URI. It works with http & https. Used when passing extra querystring data.

$grid["url"] = "new_grid.php?id=".$_GET["id"];

Dominik Kostka answered 4 years ago

Hi, I have a strange issue with Grid reloading.

I load data according to HTML select(combobox) option.

On first page load everything is OK. Data from table called STUDENTI is load into grid, because it is default combo box option.

But when I change combo box option, table called ZAMESTNANCI is not loaded. Only empty rows are rendered. And another weird thing is that number of these rows equals number of records in table STUDENTI. I think it has something to do with grid reload with AJAX call mentioned above.

I use $_Session variable to save SQL table name between $_POST requests.
this is PHP code, where I set $_Session variable for SQL table name:

if (isset($_POST["table_name"]))
{
$_SESSION["table_name"] = $_POST["table_name"];
}
else{
$_SESSION["table_name"] = "studenti";
}

I must mention that I use free version of PHPGrid control. Thanks a lot for answer.

Abu Ghufran answered 4 years ago

Short Answer: The table change (different columns) will need a full page refresh.

Long Answer: When page is load first, the grid make it's structure and columns. After that all work is done vvia ajax calls. No change is done on structure of grid.
When you change column and do ajax call, it may be returniing Json data but column mappings on grid structure is invalid now, causing blank rows.

Matthew answered 4 years ago

I had the same issue as the OP. I tried the SESSION/POST code above but it didn't work. I eventually found a solution that worked by using GET instead of POST. My PHP file is called customer.php

At the very top of the php file:
<?php
if (empty($_GET['customer']))
{
$c = "1";
}else{
$c = $_GET['customer'];
}
?>

Then when calling the form:

<form name="customerform" method="GET" action="customer.php">
<select name="customer">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
</select>
<input type="submit" name="submit" value="submit"></input>
</form>

Hope this helps someone else out.

Your Answer

3 + 17 =

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?