ComboBox MVC Core 3

Posted by: sebastian73 on 16 January 2020, 7:25 am EST

  • Posted 16 January 2020, 7:25 am EST

    Hi!

    I'm building a form for creating a new Item, and I can't find the way to initialise a <c1-combo-box> with no item selected, it always start with the first item in the collection selected.
    Is it possible to make it to start with no item selected? so I can validate the no input condition...

    Thanks!
  • Marked as Answer

    Replied 16 January 2020, 5:59 pm EST

    Hi Sebastian,

    You will need to get the reference of the ComboBox on the client-side and set its selectedIndex to -1. Please refer to the code snippet below and the sample attached:
    <script>
    c1.documentReady(function () {
    var cb = wijmo.Control.getControl('#colorBox');
    if (cb) {
    cb.selectedIndex = -1;
    }
    })
    </script>

    <c1-combo-box display-member-path="Name" selected-value-path="Value" is-required="false" id="colorBox">
    <c1-items-source source-collection="Model"></c1-items-source>
    </c1-combo-box>

    Regards,
    Ashwin

    ComboBox_Selection.zip
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels