GridView的动态绑定在上一节中已经介绍过拉,还有不会的请参考上一节,这个主要是
当gridview的ShowCheckBoxes="Leaf" 时,并且只能单选
var treeRoot;
var checkNode
function public_GetParentByTagName(element, tagName)
{
var parent = element.parentNode;
var upperTagName = tagName.toUpperCase();
while (parent && (parent.tagName.toUpperCase() != upperTagName))
{
parent = parent.parentNode ? parent.parentNode : parent.parentElement;
}
return parent;
}
function getParentNode(objNode)
{
var objParentDiv = public_GetParentByTagName(objNode,"div");
if(objParentDiv==null || objParentDiv == "undefined")
{
treeRoot = objParentDiv;
return;
}
var objID = objParentDiv.getAttribute("ID");
var objParentNode = document.getElementById(objID);
if(objParentNode.getAttribute("ID").indexOf("Nodes")<0)
{
//alter(objParentNode);
treeRoot = objParentDiv;
return;
}
getParentNode(objParentNode);
}
function setChildUnChecked(divID)
{
var objchild = divID.children;
var count = objchild.length;
for(var i=0;i<objchild.length;i++)
{
var tempObj = objchild[i];
if(tempObj.tagName=="INPUT" && tempObj.type == "checkbox")
{
if(checkNode != tempObj)
{
tempObj.checked = false;
}
}
setChildUnChecked(tempObj);
}
}
function CheckEvent()
{
var objNode = event.srcElement;
checkNode = objNode;
if(objNode.tagName!="INPUT" || objNode.type!="checkbox")
return;
if(objNode.checked==true)
{
getParentNode(objNode);
setChildUnChecked(treeRoot)
}
}
var checkNode
function public_GetParentByTagName(element, tagName)
{
var parent = element.parentNode;
var upperTagName = tagName.toUpperCase();
while (parent && (parent.tagName.toUpperCase() != upperTagName))
{
parent = parent.parentNode ? parent.parentNode : parent.parentElement;
}
return parent;
}
function getParentNode(objNode)
{
var objParentDiv = public_GetParentByTagName(objNode,"div");
if(objParentDiv==null || objParentDiv == "undefined")
{
treeRoot = objParentDiv;
return;
}
var objID = objParentDiv.getAttribute("ID");
var objParentNode = document.getElementById(objID);
if(objParentNode.getAttribute("ID").indexOf("Nodes")<0)
{
//alter(objParentNode);
treeRoot = objParentDiv;
return;
}
getParentNode(objParentNode);
}
function setChildUnChecked(divID)
{
var objchild = divID.children;
var count = objchild.length;
for(var i=0;i<objchild.length;i++)
{
var tempObj = objchild[i];
if(tempObj.tagName=="INPUT" && tempObj.type == "checkbox")
{
if(checkNode != tempObj)
{
tempObj.checked = false;
}
}
setChildUnChecked(tempObj);
}
}
function CheckEvent()
{
var objNode = event.srcElement;
checkNode = objNode;
if(objNode.tagName!="INPUT" || objNode.type!="checkbox")
return;
if(objNode.checked==true)
{
getParentNode(objNode);
setChildUnChecked(treeRoot)
}
}