0

Default rating system in Sharepoint 2013 allows to like elements in list view like this:

enter image description here

and I have no problem to get count of "likes" with FieldRef Name='LikesCount' but I wonder if is it possible to add "Like" button to each element using SPServices? and then display elements as divs like this:

enter image description here

  • You can do CSR using JSLinks. Basically you handle how the field should get rendered. – Amal Hashim Apr 7 '15 at 13:01
  • Correct me if I am wrong but you are talking about modifying current list view and rearrange elements to display as I want? – omygoodness Apr 7 '15 at 13:08
  • Yes. You can do what goes where and how it should be displayed etc. In your case I believe you just need to handle how the like field is rendered – Amal Hashim Apr 7 '15 at 13:10
  • I just need "like" button on square containing image or title and that is it – omygoodness Apr 7 '15 at 13:14
0

there's a JS function called set like that can help you, you might want to try to mix CSOm and JSOM to create the functionality you want

you only need 4 parameters the clientcontext (which is loaded for the site that contains the list)
the ListId
the ItemID
the Value =True to like/False to unlike

Microsoft.Office.Server.ReputationModel.Reputation.setLike(ClientContext,listId,ItemId,Value)

then you can execute your queryasync and switch the label text to like/unlike depending the like status.

you'll still need to query somehow the item's likecount field to check if the users has liked the item before adding the like/unlike button

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.