Get KoolPHP UI with 30% OFF!

Get number of rows in a grid

Espen
Hi,
I need to find the number of rows in a grid whenever it changes.
I thought I could utilize the OnLoad event, but it seems like it occurs before the grid object is initialized.
My goal is to automatically process the first row in a grid if it's the only row in the grid. Otherwise the user will need to select which row to process.
Any ideas how this can be done?
Espen
Posted Jan 10, 2018 Kool
David
Hi Espen,
Please try the following code and let us know if it works for you:
<?php
...
	$grid->ClientSettings->ClientEvents["OnLoad"] = "Handle_OnLoad";
...
?>
...
<script type="text/javascript">
	function Handle_OnLoad(sender,args)
	{
		var rows = sender.getMasterTable().getRows();
                alert(rows.length);
	}
</script>

Please remember to put the function Handle_OnLoad before the $grid->render(). Thanks!
Posted Jan 10, 2018 Kool -