Skip to main content

Posts

Showing posts with the label javascript

Putting an button on each line item & updating list with calculated column

Recently I was working on a feature which required me to put a button on every item in the SharePoint list's view. The button name was Assign Me . When clicked, it should update the item and put the current logged in user in the Assigned To field. I followed a hybrid approach. calculated column and custom JavaScript . I tried doing everything in calculated column.  Even though calculated columns allow writing code in JavaScript, they still have some limitations. One of the biggest hurdle is to get the ID of the item. Since calculated columns do not allow ID column, you have to be innovative. I figured out that the checkbox column in every line item has id in the tag. This is always the first column in the view (first td in the tr). Following are the steps I followed to achieve the desired result.  Step 1. Create a new calculated column with output as Number.  Step 2. Put the following formula. I use Typescript, hence replace class name with you...

Javascript/JQuery Handle Double Click

Recently I have been working on JavaScript/Query & SharePoint client side extensively. I will be posting my learnings during the past one year in the coming few posts.  Recently I was presented with a problem that the custom solution I had provided, did not behave properly when double clicked.  Scrapping through the web, I fumbled on couple of solutions. I personally like the first approach as it is very simple.  First Approach: Click Me $("#clickMe").click(function (e) {     var $this = $(this);     if ($this.hasClass('clicked')){         alert("Double click");         //here is your code for double click         return;     }else{          $this.addClass('clicked');         //your code for single click          setTimeout(function() {                ...

CSS and Javascript tips

I learned 2 interesting things today. 1. After you apply custom style sheet to your content in SharePoint, it is still not getting applied when you check in browser. The reason for that is the SharePoint overrides your style (css class). To over come this situation, you can declare your styles in css class as !important. This lets SharePoint know that your css class is priority. .mediumText {     font-family: Arial !important;     font-size: 9pt !important; } 2. If you want to execute javascript code after successful ASP.net validation of controls (required field validator etc...) you need to write a small javascript function which calls Page_ClientValidate to fire validation and get its status (successful - true; unsuccessful-false). and here is the button markup... Happy Coding Vighnesh Bendre