Get KoolPHP UI with 30% OFF!

Kool Grid - Saving details of row before edit

Kevin
when an item in a row such as 'room number' is changed i need to be able to save the old room number to a audit table to say it was changed by user date and time and or save the data in the entire row to an audit table so I have a record of what it was before it was changed and that it was canged by usernmae on date at time.
Posted Aug 11, 2015 Kool
David
You could check the following two events to backup the data before confirming edit:
http://doc.koolphp.net/Controls/KoolGrid/Javascript/ClientSide_Events/index.php#OnBeforeRowStartEdit
and:
http://doc.koolphp.net/Controls/KoolGrid/Javascript/ClientSide_Events/index.php#OnBeforeRowConfirmEdit
Let me know if these are not enough for your case. Thanks!
Rgds,
Posted Aug 12, 2015 Kool
Kevin
Hi I have looked at those before without any luck and gave up trying to obtain the row data and then write it to an auditLog table
Posted Aug 13, 2015 Kool
Abraham
as David says. you need OnBeforeRowStartEdit handler..
<?php
...
	$grid->ClientSettings->ClientEvents["OnBeforeRowStartEdit"] = "Handle_OnBeforeRowStartEdit";
...
?>
...
<script type="text/javascript">
	function Handle_OnBeforeRowStartEdit(sender,args)
	{
		var _row = args["Row"];
		alert("A row is is about to be edited.");
		return true; // Approve action
	}
</script>

once you get the row stored in:
var _row = args["Row"];

You can hanlde the _row arry data.. I bet the best way to do it is to send it trought ajax to a handlechanges.php.
Posted Aug 13, 2015 Kool
Igor
Hi,
you can write before update trigger, for example:
(mysql)
CREATE TRIGGER `name` BEFORE UPDATE ON `tableName`
 FOR EACH ROW BEGIN
    INSERT INTO audiTable
    (
      value1,
      value2,
      value3,
     valueN
    )
    VALUES
    (
     OLD. value1,
      NEW.value2,
     NEW value3,
     NEW.valueN
    );
  END

Chears,
Igor
Posted Jun 9, 2016 Kool
Anthony Amolochitis
$row->DataItem has the data of the row before the update. Basically the current state of the row.
$args['NewDataItem'] has the data submitted by the form from post
I hope this helps
Posted Jun 10, 2016 Kool