Ver Mensaje Individual
  #4 (permalink)  
Antiguo 06/12/2010, 17:17
slimnot4
 
Fecha de Ingreso: noviembre-2010
Mensajes: 24
Antigüedad: 14 años, 1 mes
Puntos: 0
Respuesta: tree view con checkbox

Hola que tal aqui les dejo un scrip muy bueno que me ayudo a solucionar el problema de las selecciones del treeview con checkbox la primera parte
function client_OnTreeNodeChecked()
{
var obj = window.event.srcElement;
var treeNodeFound = false;
var checkedState;

if (obj.tagName == "INPUT" && obj.type == "checkbox")
{
var treeNode = obj;
checkedState = treeNode.checked;
do
{
obj = obj.parentElement;
} while (obj.tagName != "TABLE")

var parentTreeLevel = obj.rows[0].cells.length;
var parentTreeNode = obj.rows[0].cells[0];
var tables = obj.parentElement.getElementsByTagName("TABLE");
if(obj.tagName == "TABLE")
{
if (treeNode.checked)
{
var head1 = obj.parentElement.previousSibling;
if(head1!=null)
{
if(head1.tagName == "TABLE")
{
var matchElement1 = head1.getElementsByTagName("INPUT"); //matchElement1[0] gives us the checkbox and it is checked
if(matchElement1.length>0)
matchElement1[0].checked = true;
}
}
else
{
head1 = obj.parentElement.previousSibling;
}
if(head1!=null)
{
if(head1.tagName == "TABLE")
{
var head2 = obj.parentElement.parentElement.previousSibling;
if(head2!=null)
{
if(head2.tagName == "TABLE")
{
var matchElement2 = head2.getElementsByTagName("INPUT");
if(matchElement2.length>0)
matchElement2[0].checked = true;
}
}
}
}
else
{
head2 = obj.parentElement.previousSibling;
}
if(head2!=null)
{
if(head2.tagName == "TABLE")
{
var head3 = obj.parentElement.parentElement.parentElement.prev iousSibling;
if(head3!=null)
{
if(head3.tagName == "TABLE")
{
var matchElement3 = head3.getElementsByTagName("INPUT");
if(matchElement3.length>0)
matchElement3[0].checked = true;
}
}
}
}
else
{
head3 = obj.parentElement.previousSibling;
}
if(head3!=null)
{
if(head3.tagName == "TABLE")
{
var head4 = obj.parentElement.parentElement.parentElement.pare ntElement.previousSibling;
if(head4 != null)
{
if(head4.tagName == "TABLE")
{
var matchElement4 = head4.getElementsByTagName("INPUT");
if(matchElement4.length>0)
matchElement4[0].checked = true;
}
}
}
}
}//end if - checked
if (!treeNode.checked) {
var chk1 = false;
head1 = obj.parentElement.previousSibling;
var pTreeLevel1 = obj.rows[0].cells.length;
if(head1!=null)
{
if(head1.tagName == "TABLE")
{
var tbls = obj.parentElement.getElementsByTagName("TABLE");
var tblsCount = tbls.length;
for (i=0; i < tblsCount; i++)
{
var childTreeLevel = tbls[i].rows[0].cells.length;
if (childTreeLevel == pTreeLevel1)
{
var chld = tbls[i].getElementsByTagName("INPUT");
if(chld.length>0)
{
if (chld[0].checked == true)
{
chk1 = true;
break;
}
}
}
}
var nd = head1.getElementsByTagName("INPUT");
if(nd.length>0)
{
nd[0].checked = chk1;
}
}
}