0

I have a list in SharePoint 2013, and currently I am trying to get the cell ID of the column in a list using the developer tools. I am having a problem finding it (My IE is not working and Firefox does not seem to show it). How do I find the ID? I need the ID to attach a JS file to the column. Meaning, that I would like to link the function of the JS file to the list so that the JS file will do an external function to one cell and then place the result in another cell. In this case it would be a date that is being updated.

I was thinking that I could do this using with out an ID for i do not need an ID to grab an item with jQuery.

meaning:

$('th:contains:"Title of column").some_jQuery_command // Is this correct?

Would this approach be right for I would like update all the dates in the column?

Rethinking it, I thought that this may be a good approach:

$(document).ready(function () { 

    var myValue = $( 'th:contains:"Title of column' ).val(); // Is this the right approach? 


function MyCustomFunction(myValue)
    {
    // my process to update the date
    }
}

Could some advise?

another way: using Client Side Rendering

I have explored the Client Side Rendering suggested below, but sine i am new to it please advise on how to make it work...

function selectItem(){  // function for selecting all list items in row by ID

    for (var i=0; i <ctx.ListData.Row.length;i++){
        if (parseInt(ctx.ListData.Row[i].ID) !== 0) // this incrementation is not needed, right? 
            SelectRrowByIndex(ctx,4,true); // 4 being the ID of the column in the row which i would like select. but what now? 

// can i apply my javescript here? 
        }
    }
}
  • 1
    Please explain first what you mean with "I need to attach a JS file to a column" – Danny '365CSI' Engelman Nov 22 '15 at 12:52
  • Meaning, that i would like to link the function of the JS file to the list so that the JS file will do an external function to one cell and then place the result in another cell. I added this comment to my original question. – joe 222 Nov 22 '15 at 13:06
2

Forget about that old school jQuery coding where you apply fixes to the page.

What you want is done with CSR - Client Side Rendering since SP2013

Start by understanding all examples at:

Note that those examples are from the early SP2013 days and not necessarily demonstrate good coding practices

For any CSR development you must use:

  • Will the examples also show me how to apply the logic of the JS file to two entire columns, automatically? Meaning that you take one date form one column and update the other but throughout the entire column? – joe 222 Nov 22 '15 at 19:40
  • What i am trying to do is apply this logic to the entire column, I already have the javascript with the logic and just want to apply it to the columns for the update to go through. I will learn this in the now and in future but right now I need to finish my project. Any ideas on how to link the columns? – joe 222 Nov 22 '15 at 19:53
  • Learn that CSR stuff, Joe, it will make future developments a breeze – Danny '365CSI' Engelman Nov 23 '15 at 11:35

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.