CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Editable Grid w/ Auto Rows

Print topic Send  topic

Author Message
Anothersledhead


Posts: 44
Posted: 02/15/2005, 1:41 PM

I get a Undefined offset: error in the "Editable Grid with new rows added automatically example" when I try to recreate it. I can tell that this error has to do with the counting of the rows but am unable to find the cause. Where should I look for help on this. I have done some google searches and have found that there is an issue with this in different versions of PHP is this the case? Do I need to update my version of PHP or does the code in the example need to be reworked?

Thanks
View profile  Send private message
lvalverdeb

Posts: 299
Posted: 02/16/2005, 7:23 AM

I used to get that same error but can't remember the reason why :-/ . Anyhow, since I use that functionality quite a bit, I wrote the following functions which fixed the "Undefined offset" error and made it easier to implement it as well.
  
function HideEmptyRows(&$Form,$CurrRow) {  
	$Form->RowIDAttribute->SetValue($CurrRow);  
	//Configure the row's properties based on its state (empty or filled)  
  	if (($CurrRow <= $Form->PageSize) && ($CurrRow <= $Form->ds->RecordsCount)) {  
     	$Form->RowNameAttribute->SetValue("FillRow");  
  	} else {  
   		$Form->RowNameAttribute->SetValue("EmptyRow");  
   		$Form->RowStyleAttribute->SetValue("style=\"display:none;\"");  
		if ($CurrRow <= $Form->TotalRows)  
		{     	  
   			if (isset($Form->RowErrors[$CurrRow]))  
			{  
				if($Form->RowsErrors[$CurrRow]) {  
      				$Form->RowStyleAttribute->SetValue("");  
    			}  
			}  
		}  
  	}  
	return $Form;  
}  

In order to use it you have to:

1) "include" it in your Common.php
2) Just like in the example define a global $RowNumber with the initial value set to zero.
3) Call the call it from the grid's BeforeShowRow event like this:

  
$RowNumber++;  
HideEmptyRows($YourGridObjectGoesHere,$RowNumber);  

4) Also, I "cloned" the Javascript function in the example and made it generic to handle the "Add New" functionality. The code is as follows:

  
function AddRow(myForm)  
{  
    var result;  
	var NS6 = (!document.all && document.getElementById) ? 1 : 0;  
	var IE  = (document.all) ? 1 : 0;  
	var FormState = myForm.FormState.value.split(";");  
	var AllLength = parseInt(FormState[0])+parseInt(FormState[1]);  
  	if (parseInt(FormState[0]) == 0 ) {  
      FormState[0] = 1;  
  	}  
	var i;  
  	for (i=FormState[0]; i<AllLength; i++) {  
     	var objRow = document.getElementById(i);  
		if (NS6) {  
       		if (objRow.style.display == "none") {  
           		objRow.style.display = '';  
   				result = i;  
				break;  
       		}  
     	} else {  
       		if (objRow.style.display == "none") {  
           		objRow.style.display = "block";   
   				result = i;  
				break;  
       		}  
	 	}  
  	}  
  	if (i >= AllLength)   
      myForm.AddRowBtn.disabled = true;  
	return result;  
}  

5) The AddRow function you have to call it from the Client On-Click Event and pass as parameter the grid's form name. For example:

  
result = AddRow(document.forms["yourformnamegoeshere"]);  

the only catch in the JS function is that your "Add New Button" must be called AddRowBtn.

6) You need to follow the other steps in the tutorial with regards to the manual HTML tags, etc.

Hope this helps

Luis

_________________
lvalverdeb
CR, GMT-6
XAMPP/Ubuntu/CCS3.2/4
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.