70001064 Get the number of currently selected items using vdSelectionModified event

Article 70001064
Type Wish
Product WebJS
Date Added 4/21/2017 12:00:00 AM
Fixed 7.7011.0.4 (4/22/2017 12:00:00 AM)
Submitted by Brendan Fry

Summary

How to get the number of currently selected items using vdSelectionModified event

Solution

In version 7011.0.4 new properties was added in vdSelectionModified event arguments
userselectedCount : Reurns the count of the original items that user select before filter out
ItemIndex : Returns the zero base index of the selectedItem property relative to userselectedCount property

Example:
vdcanvas.vdSelectionModified = _vdSelectionModified;//We set the event in the vdrawInitPageLoad()
Then we create the function which takes as parameteres args
function _vdSelectionModified(args) {
    //Now we add the selectedItem only if user selects 5 items
    if (args.userselectedCount != 5) args.cancel = true;//cancel=true; means that the entity can not be select.
    if (args.ItemIndex == 4) args.finish = true;//finish the selection if 5 items was added
} 

Send comments on this topic.