Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
55
Multiple selection checkboxes not working with itemTemplate
posted

Hi,

I'm trying to set up my igCombos to use multiple selection with checkboxes, but they don't seem to work with itemTemplates. Here is my igCombo setup:

$('selector').igCombo({

dataSource: dt,
valueKey: 'NodeId',
textKey: 'ConcatenatedFields',
itemTemplate: rowTemplate,
filteringType: 'local',
width: '100%',
selectItemBySpaceKey: false,
multiSelection: "onWithCheckboxes",
virtualization: true,

selectionChanging: function (evt, ui) {
    // Veto any selectionChanging events which are caused by
    // a keypress that is not ENTER.
    if (evt.keyCode !== undefined && evt.keyCode !== 13) {
        return false;
    }
},
selectionChanged: function (evt, ui) {
    // Work with selected rows
}
});

dt is the data source, an array of Javascript objects. It is of the form [{ key1: "value1a", key2: "value2a", key3: "value3a" },{ key1: "value1b", key2: "value2b", key3: "value3b" },{ key1: "value1c", key2: "value2c", key3: "value3c" }]

rowTemplate is the itemTemplate string. It is dynamically generated just before the igCombo is initialised. It is of the form "<div><span class='column1'>${key1}</span><span class='column2'>${key2}</span><span class='column3'>${key2}</span></div>".

Using this setup, checkboxes render correctly in the dropdown, with pointer-cursor on mouseover and everything. But when the checkbox is clicked, the igCombo performs a single select on that row.

Does multiple select with checkboxes not work with templated rows, or have I implemented it wrong?

Thanks,

Mike

Parents
No Data
Reply
  • 55
    Verified Answer
    posted

    Never mind, I realised what it was.

    My selectionChanged function was written in the context of a single-selection combo box. As part of that, it clears the igCombo's selection once it's finished working with the selection data.

    So basically my own code was stopping igCombo from working as I expected. Hopefully I haven't wasted anyone's time.

    Cheers,

    Mike

Children
No Data