passing variable from URL in add/edit mode

Questionspassing variable from URL in add/edit mode
varun asked 11 years ago

Hi Abu,
I am trying to pass the values obtained from the URL to the add/edit mode of the grid.
In detail:Say this is my URL(WWW.xzy.com/hello.php?id=1&name=Dell).
i want to pass this id and name into some column,when i open in add/edit mode of the new page with the above URL.
How to pass it, i am trying to copy it to local variable,is it possible to set grid column values to local variable?

5 Answers
Abu Ghufran answered 11 years ago

Hello,

You can simply set this value in column using following config.

$col["name"] = "pc_name";

$col["editoptions"] = array("defaultValue" => $_GET["name"]);

defaultValue only comes when adding. If you want same value at edit, you need to set "value" instead of "defaultValue"

varun answered 11 years ago

thank you

Mario answered 8 years ago

Hi,

is it possible to do the same with a query?
For instance

http://WWW.xzy.com/hello.php?id=1&name=myqueryterm

The result should be as if I sarch in column "name" the term "queryterm"

Is it possible to pre-filter a grid by an url-parameter? Or do I have to set up for each case an own file with own select?

Best regards,
Mario

Abu Ghufran answered 8 years ago

This feature is available in latest build.

Demo: http://www.phpgrid.org/demo/demos/search/search-onload-url.php?list1_total=%3E100&list1_name=ana
Code: http://www.phpgrid.org/demo/demos/search/search-onload-url.phps

Usage: Add querystring param, gridid_colname=value e.g. list1_name=ana

Kindly email me your order number for updated build.

Mario answered 8 years ago

I thank you. It works great! It works according this pattern

http://www.domain.com/filename.php?list1_colfieldname=searchedteam

One has to combine
p.e. list1 = which is the name in the grid-output, mostly last line, like …

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

… with the colfieldname
p.e. "colfieldname" = which is the name of the column.

Your Answer

2 + 1 =

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?