GridView avec Checkbox - manipulation JS
Bonjour à tous, j'ai un GridView rempli depuis une source oleDB, et dans ce gv j'ai une première colonne avec des CheckBox.
Ce que je veux:
-Quand on coche une chkb, la row est sélectionnée (surbrillance);
-On ne peut avoir qu'une seule row de sélectionnée (donc décocher toutes les autres);
-Récupérer une cell de la row sélectionnée dans un simple label;
Ce que j'ai:
Après plusieurs manips infructueuses, j'ai fait la selection en JS, voilà mon code actuel:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
|
<script type="text/javascript">
function HighlightRow(rowChkB)
{
rowChkB.parentElement.parentElement.style.backgroundColor='#D91616';
rowChkB.parentElement.parentElement.style.color='white';
}
else
{ rowChkB.parentElement.parentElement.style.backgroundColor='white';
rowChkB.parentElement.parentElement.style.color='black';
}
}
</script> |
Là ça marche, seulement ça ne fait que surligner une ligne (plusieures si on en sélectionne d'autres).
Donc j'ai ajouté ça:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
function HighlightRow(rowChkB)
{
var IsChecked = rowChkB.checked;
if(IsChecked)
{
Parent = document.getElementById('GridView1');
for(i=0; i<Parent.length; i++)
{
if(items[i].id == rowChkB)
{
rowChkB.checked = false;
}
}
rowChkB.parentElement.parentElement.style.backgroundColor='#D91616';
rowChkB.parentElement.parentElement.style.color='white';
}
else
{
rowChkB.parentElement.parentElement.style.backgroundColor='white';
rowChkB.parentElement.parentElement.style.color='black';
}
}
// rowChkB: étant mon ID checkbox dans mon gridview |
Si vous pouviez m'aider ce serait génial :D
Merci d'avance,
Cordialement