2

I have an SP list with a hyperlink column. If someone click on it I would like to get the ID of the row and store it before redirect to the next page. I am new to both SP and JS so any idea how to approach this is welcome! Thanks you for the help!

  • You could probably use JSLink for the same to achieve. In that you might mention click event when hyperlink is clicked so that you can save the current item ID. – Pradip R. Oct 30 '17 at 11:37
  • Thanks you very much for the idea, I am looking into it! :) – Nefri Oct 30 '17 at 12:18
  • Using Content Query web part and display required fields. When anyone click on the item it will redirect to row ID. – san Oct 31 '17 at 4:37
2

For getting row ID on clicking item. You need to implement jslink on column and implement rendering as bellow shown It helps you for for question.

(function () { 

    // Create an object that have the context information about the fields that we want to change the rendering of.  
    var priorityFiledContext = {}; 
    priorityFiledContext.Templates = {}; 
    priorityFiledContext.Templates.Fields = { 

        // Apply the new rendering for these fields on List View 
        "Overall_x0020_Status": { "View": priorityFiledTemplate }, 
        "Time_x0020_Status": { "View": priorityFiledTemplate },
        "Cost_x0020_Status": { "View": priorityFiledTemplate },
        "Scope_x0020_Status": { "View": priorityFiledTemplate }
    }; 

    SPClientTemplates.TemplateManager.RegisterTemplateOverrides(priorityFiledContext); 

})(); 

// This function provides the rendering logic for the list view 
function priorityFiledTemplate(ctx) { 

    var priority = ctx.CurrentItem[ctx.CurrentFieldSchema.Name]; 

    // Return html element with appropriate color based on value 

    switch (priority) { 
        case "Red": 
        //Instead of the word "red" show and image from the Style Library
            return "<img src='https://decode247.sharepoint.com/Style%20Library/red.png' align='center'>";
            break; 
        case "Yellow": 
            return "<img src='https://decode247.sharepoint.com/Style%20Library/yellow.png'>";
            break; 
        case "Green": 
            return "<img src='https://decode247.sharepoint.com/Style%20Library/green.png'>";
    } 
}  

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.