PRB: Client-Side Grid DTC Does Not Navigate to Row with Internet Explorer 5 or Later (266152)



The information in this article applies to:

  • Microsoft Visual InterDev 6.0
  • Microsoft Internet Explorer (Programming) 5
  • Microsoft Internet Explorer (Programming) 5.01
  • Microsoft Internet Explorer (Programming) 5.5

This article was previously published under Q266152

SYMPTOMS

For a Visual InterDev 6.0 Grid Design-Time Control (DTC) that has a scripting platform of Client (IE 4.0 DHTML) and row navigation enabled, users who click directly on one of the grid rows from within a Web browser will navigate directly to that row if the client is Internet Explorer 4.x. If the client is Internet Explorer 5 or later, the navigation will not occur.

CAUSE

The Visual InterDev Script Library was written before Internet Explorer 5 was released. The Grid onclick event depends on document.selection.type to return a value of "None". Starting with Internet Explorer 5, when an HTML table is clicked, document.selection.type returns "Text" instead of "None". This change causes the Grid onclick event to exit before navigating to a new row.

RESOLUTION

To resolve this problem, you can associate the Grid DTC's onclick event with a custom function by using the following code (note that the Grid DTC in this case is named Grid1):
<BODY onload=window_onload()>
<SCRIPT LANGUAGE=javascript>

function window_onload()
{
  Grid1.onclick = Grid1_onclick;
}

function Grid1_onclick()
{
	var objDataGrid = event.srcElement;
	var bFound = false;
	var nIndexAux = 0;
	var nIndex = 0;
	
	if (document.selection.type != 'None' && document.selection.type != 'Text')
	    return;
	
	while ((!bFound) && (typeof(objDataGrid) != 'undefined') && (objDataGrid != null))
	{
		if (typeof(objDataGrid.navbar) == 'string')
			return;
			
		if (objDataGrid.tagName == 'TR')
		{
			nIndex = nIndexAux;
			nIndexAux = objDataGrid.rowIndex;
		}
		
		if ((typeof(objDataGrid._auxID) == 'string') && (objDataGrid._auxID == 'DataGrid'))
			bFound = true;
		else
			objDataGrid	= objDataGrid.parentElement;
	}
		
	if ((bFound) && (typeof(objDataGrid.hiliteAttributes) != 'undefined') && (objDataGrid.hiliteAttributes != null) && (objDataGrid.hiliteAttributes.length))
	{
		var objRS = objDataGrid._objDataSource;

		if ((typeof(objRS) != 'undefined') && (objRS != null))
		{
			var nPos = objRS.absolutePosition;
			var nOffset = objDataGrid.pageSize * objDataGrid._curPage;
				
			if ((this.colHeader.length == 0) || !this.displayHeader) ++nIndex;
			
			if (nIndex != 0)
				objRS.moveAbsolute(nOffset + nIndex);
					
			objDataGrid.focus();
		}		
	}
}
</SCRIPT>
				

Modification Type:MajorLast Reviewed:5/29/2003
Keywords:kbCtrl kbprb kbScript KB266152