Skip to content

Instantly share code, notes, and snippets.

@dudelis
Last active May 4, 2018 20:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dudelis/765febe38e1620372ee0dfd5100ec9c2 to your computer and use it in GitHub Desktop.
Save dudelis/765febe38e1620372ee0dfd5100ec9c2 to your computer and use it in GitHub Desktop.
K2: Select Listview rows with checkboxes
//You need to do the following for the code to work:
//1. Add Literal datalabel to the list view and call it 'dlblScript'.
//2. Add a new column into the list view, add literal datalabel there and add a piece of the following html inside:
<input type="checkbox" class="custom-box"/>
//3. Add the following js into the dlblScript:
<script>
var contentTable = $("span[name='dlblScript']").closest('.grid').find('.grid-content-table')[0];
var observer = new MutationObserver(function(mutations){
$(contentTable).find('.custom-box').each(function(i, val){
if ($(this).prop('checked')){
$(this).closest('tr').addClass('highlighted selected');
} else{
$(this).closest('tr').removeClass('highlighted selected');
}
});
});
var config = {attributes:true, subtree:true, characterData: true};
observer.observe(contentTable, config);
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment