Get value of selected checkbox in Listview webpart - SharePoint 2010
Here is what I added in my DFWP’s XSLT to get a check box in each row.
- In SPD, add a Data View webpart to the page Date View >Insert Data View
 - Configure columns
 - Add an extra column to the left of the rendered data view (you can do this by selecting any left most cell and then Table > Insert > Column to the Left)
 - In the newly generated column, select first (or any <TD>) and then add a HTML check box (Insert > HTML > then Input (Checkbox)
 - Set the value property of the checkbox to use ID column’s value
 - Also add a html button somewhere outside the DFWP. In my example, I 
will attach an event handler that will read the check box values into an
 Array. <input
id=”actionButton”
type=button
value=”Get Selected Item IDs”
/> - 
Now add the following script just after the button element.
<script>
document.getElementById(“actionButton”).onclick = function() {
var idValues = new Array();
$(“input:checkbox:checked”).each(function() {
idValues.push(this.value);
})
alert(idValues.toString());
}
</script>
 - Here is the output
 
References:
1 comments:
There's something missing in this solution
Post a Comment