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.
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