Question

There's a web part on a list view page with button element on it. When user clicks the button all selected list items get deselected. I cannot change button element to input because it's Office UI Fabric component. I added type='button' attribute to the button so it won't reload the page, but it didn't help with selection. Any ideas?

Here's code I place to AllItems.aspx page. On button click all selected items get deselected:

<button type='button' onclick='test();return false;' >test</button>
<script>
function test() {
//nothing here
}
</script>
Was it helpful?

Solution

Try it. Dont forget to change web part id (MSOZoneCell_WebPartWPQ2 - id of list view web part) if it doesn't work:

var elem = document.getElementById("MSOZoneCell_WebPartWPQ2");
if (elem != null) {
    var dummyevent = new Array();
    dummyevent["target"] = elem;
    dummyevent["srcElement"] = elem;
    WpClick(dummyevent);
    SP.Ribbon.WebPartComponent.$3.deselectWebPartAndZone = function () { };
}

OTHER TIPS

You can add a return false; to the button onclick. That should prevent the postback.

Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top