add active user name in grid

Questionsadd active user name in grid
sadegh asked 3 weeks ago

Hello
I want to read the user name from the session, and then put a function in one of the columns at the time of calling the  add function.

1 Answers
Abu Ghufran Staff answered 3 weeks ago

To set session value in some field while showing add form, you can set it as default value. e.g.

$col[“name”] = “userid”;
$col[“editoptions”][“defaultValue”] = $_SESSION[“userid”];

and you can make such field hidden as well, $col[“hidden”] = true;

If you want to set it after postback, you can use on_insert event and set it there.

$e[“on_insert”] = array(“add_client”, null, true);
$g->set_events($e);

function add_client(&$data) {
$data[“params”][“userid”] = $_SESSION[“userid”];
}

Refer http://phpgrid.org/docs/grid-events/ and demo code for help.

_________________________
Abu Ghufran - Dev Team
PHP Grid Framework
 
Your Answer

3 + 19 =

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 / 5. Vote count:

As you found this post useful...

Follow us on social media!

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

Let us improve this post!