Disable selection and itemInvoke event for a specific item in the list

I have a list. By default, all elements have itemInvokeand single-selection. But now I would like to disable selectionand itemInvoke(both the event and the animation) for one specific element with the identifier "disableMe". Is there any way to do this? Or you can disable the event for the entire group (not the entire list).?

+3
source share
1 answer

Answering my question, because I managed to find out today. Please advice if you have a better solution to this problem.

" Metro" ListView Right-Click "" / "". , MSPointerDown . " ", oncontextmenu .

itemTemplate Javascript:

function listViewItemTemplate(item) {
    // data has boolean properties called 'doNotSelectMe' and 'doNotInvokeMe'
    var data = item.data._value;

    var itemElement = document.createElement('div');
    var itemElement.id = 'testElement';

    if (data.doNotSelectMe) {
        // disable mouse selection
        itemElement.oncontextmenu = function (e) { e.stopPropagation(); };
        // disable touch selection
        itemElement.addEventListener('MSPointerDown', function (e) {
                                          e.stopPropagation();
                                     });
    }

    if (data.doNotInvokeMe) {
        //disable item invoke event
        itemElement.onclick = function (e) { e.stopPropagation(); };
    }

    return {element: itemElement}

}
+4

All Articles