custom action – no action on current table but action on another

Questionscustom action – no action on current table but action on another
Wing asked 6 years ago

there are 2 grids: my-positions and all-positions

from all-positions, I can click on a custom column that has a link name ‘select’. It is built like the ‘buy’ column in https://www.phpgrid.org/demo/demos/appearance/custom-row-button.php

$col = array();
$col[“title”] = “Select”;
$col[“name”] = “buy_button”;
$col[“width”] = “30”;
$col[“align”] = “center”;
$col[“search”] = false;
$col[“sortable”] = false;
$col[“default”] = “<a href=’#test’ class=’action-btn’>Select</a>”;
$cols[] = $col;

When the select link is clicked, I want to insert the select row’s position-id column value from the ‘all-positions’ grid, and insert it into the ‘my-positions’ grid. The ‘my-positions’ grid would refresh too.

how can this be done?

Thanks.

1 Answers
Abu Ghufran Staff answered 6 years ago

Step1: Connect a javascript function on click on ‘anchor’ tag. Also pass the column names showing data required for insert. e.g. id with placeholder { }

$col[“default”] = “<a href=’#test’ onclick=’moveItem({id})’ class=’action-btn’>Select</a>”;

Step2: In JS function use this code as in demo custom forms insert function:
https://phpgrid.org/demo/demos/editing/custom-forms.phps + 175

Changes required would be list1 to your grid id (177)
Line 181, serialize() is not required. You will pass the function param. e.g. request=”id=”+id;

The function will refresh the grid as well in which new row is inserted.

You can also check demo for more:
https://phpgrid.org/demo/demos/editing/custom-forms.php

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Your Answer

9 + 11 =

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?