Using Sharepoint Multi-Lookup selected values to set checkboxes in datatables table
Using Sharepoint Multi-Lookup selected values to set checkboxes in datatables table
Zer0Admin
Posts: 6Questions: 2Answers: 0
I am able to get the already selected items in a multi-lookup field in my sharepoint list.
What I am having trouble doing is actually setting the already selected fields in my table based on what was already selected in the multi-lookup list item.
The block of code I am focused on is:
$("[title='Applicable Requests selected values'] option").each(function () {
IdRequest = ReturnRequestId($(this).text());
table.$('tr', {'search':IdRequest}).prop('checked',true);
});
This block is called as a last step when the page is loaded. Again I am only checking those that are already checked. Any nudge is appreciated.
This discussion has been closed.
Answers
Couuld you give a link to the page so we can take a look please? I'm not really familiar with how SharePoint works.
Allan
Unfortunately the site is not externally exposed. Be glad, keep your distance. SharePoint is like a black hole.My plan was to use the search to locate the rows I needed checked and check them. What seems to be happening is that I am checking all of them instead. It seems that I should probably iterate through the table and set the checkbox for those that match. I will give that a go first.
Below is the code for my most recent attempt.
Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
I'm not seeing where you set the .data() to your updated values. 'd' is the object of the columns, so you need to push that back into the table memory and .draw() should then render it into HTML.
Something like
As I was reviewing all the code, I noticed the rowCallback which is basically doing the same thing I wanted to do. I solved my problem by placing
just after
$(document).ready(function() {
//This actually caused other issues so this is not the final solutions.