Hi! I have written on_clone custom function for test that works, but shows error "200: OK. Status: parsererror":
…
$e["on_clone"] = array("clone_row","",false);
…
function clone_row($data)
{
mysql_query("INSERT INTO test_table (Name) VALUES ('TEST')");
}
…
I used "null", "" and null values on array, but the result is the same.
I have licensed version.
Can you help me?
Thank you!
There is a fix required in core lib (lib/inc/jqgrid_dist.php)
In 'fx_clone_row = function (grid,id)' … change datetype from 'json' to 'html'
fx_clone_row = function (grid,id)
{
myData = {};
myData.id = id;
myData.grid_id = grid;
myData.oper = 'clone';
jQuery.ajax({
url: "<?php echo $this->options["url"]?>",
dataType: "html", // <<<<<<<<<<<———————————————–
data: myData,
type: "POST",
…
Sorry for reopening the issue, but if I use on_clone function this way, it seems that params data not work. Removing the fix does not work either.
…
$e["on_clone"] = array("clone", "null", true);
…
function clone($data)
{
$data["params"]["Name"] = "TEST";
}
…
The on_clone event don't have such param that allow changing data.
e.g. data content are:
Array
(
[id] => 14
[params] => Array
(
[0] => invdate
[1] => client_id
[2] => amount
[3] => tax
[4] => total
[5] => note
[6] => closed
[7] => ship_via
)
)
id: the row id (pk) being copied
params: all the fields that will be copied.
If you wish to change the data, you can run another select query to fetch data of row id, and run custom insert.
If you don't wish to run default clone insert query, and write your own logic, you can put 3rd argument to false.
$e["on_clone"] = array("clone", null, false);