Monday, July 14, 2014

Get value of checked row in Listview Webpart

Introduction

I am going to share my idea about getting value of checked row in ListView webpart. I have achieved this using javascript.

Using javascript

After placed the webpart in sitepages. Just go to your sitepages in visual studio. Then add view button or label in that page to trigger the javascript. 

<input type="button" value="view" onclick="ViewCheckedElement()" />

Add the below script at bottom of sitepage or js file you already have.



function ViewCheckedElement() {
var r = $("tr.s4-itm-selected").attr("iid").split(",")[1];
alert(r);
}

This tr.s4-itm-selected class name will be added when we select the row in listview. We may find id of the row iid attribute.






Deploy the solution in your farm. That's all, an alert will come with checked items when you clicked the view button.

No comments:

Post a Comment