create button in List/Library view for each item

// loop through all views on the page
$("table.ms-listviewtable").each(function(a) {

// is the WebPart view named  with list name ?
if ( $(this).attr("summary") == "ListName")// here list name is your List name
{
// open the TBODY tag
$(this).find("tbody").each(function(b) {

// loop through <tr> tags (table row)
$(this).find("tr").each(function(c) {

var docItemID = "";

// loop through <td> tags (table columns)
// find the Item ID for this document
$(this).find("td").each(function(d) {
$(this).find("div.itx").each(function(e) {
docItemID = $(this).attr("id");
console.log("FOUND IT: " + docItemID);
});
});


// append the button html as the last column in the row
if (docItemID.toString().length > 0) {
$(this).append("<td><button id='"+docItemID+"' class='buttonClass'>Move Item</button></td>");
}
});

});

}
});


Comments

Popular posts from this blog

SharePoint 2013 REST API CRUD Operations

Add List Item Attachments to Task Form using Nintex Workflow and Forms

SharePoint ULS log viewer tool comparison and verdict