guyS's WebLog

IShare, My DotNet Fingerprint

DataGrid JS Functionality

I have Just added a short article regard attaching your grids JS functionality

I did not add the following JS functions (maybe I should). The functions enable to get a reference to an input element from .NET page. This can be use within our JS Edit Row validate function. There we will need to get the Current Grid Edit Row input elements in order to commit our validations

function getControl(sItemName)
 {  
  var oItem = null;
  
  if (document.forms.length == 1)
  {
   oItem = IsElementExistInForm(document.forms[0],sItemName);
   return oItem;
     
  }
  else
  {  
   for (var i = 0; i < document.forms.length; i++)
   {
    oItem = IsElementExistInForm(document.forms[0],sItemName);
    if (oItem != null)
     return oItem;
   }
  }
  
  return null;
 }

function IsElementExistInForm(oFrm,sName)
 {
 var index = -1 ;
 var oCurrItem = null;
 var s = "";
 
 if (oFrm.all.length == 1)
 {
  oCurrItem = oFrm.all(0);
  
  if (oCurrItem!=null)
  {
   //alert(oCurrItem.tagName);
   s = "" + oCurrItem.id ;
   index = s.indexOf(sName);
   //alert(oCurrItem.id);
   //alert(index);
   if (index >= 0 )
    return oCurrItem; 
  }
 }
 else
 {
 for (var j = 0; j < oFrm.all.length; j++)
 {
  oCurrItem = oFrm.all(j);
  if (oCurrItem!=null)
  {
   //alert(oCurrItem.tagName);
   s = "" + oCurrItem.id ;
   index = s.indexOf(sName);
   //alert(oCurrItem.id);
   //alert(index);
   if (index >= 0 )
    return oCurrItem;
  }
 }
 }
 return null;
}

 

Comments

No Comments

Leave a Comment

(required) 

(required) 

(optional)

(required)