New to Kendo UI for jQuery? Start a free 30-day trial
Adding New Items
You can enable users to add a new item when the search results do not match their filtering conditions.
For a runnable example, refer to the demo on adding new items to the MultiSelect.
-
Initialize the MultiSelect.
html<input id="products" style="width: 100%;" /> <script> $(document).ready(function() { var data = [ { ProductName: "Beer", ProductID: "1" }, { ProductName: "Tee", ProductID: "2" }, { ProductName: "Coffee", ProductID: "3" } ]; $("#products").kendoMultiSelect({ filter: "startswith", dataTextField: "ProductName", dataValueField: "ProductID", dataSource: data }); }); </script>
-
Refer the data source of the MultiSelect.
jsvar widget = $("#products").getKendoMultiSelect(); var dataSource = widget.dataSource;
-
Implement the confirmation dialog.
jsif (confirm("Are you sure?")) { dataSource.add({ ProductID: 0, ProductName: value });
-
Sync the data to update the records.
jsdataSource.one("sync", function() { widget.select(dataSource.view().length - 1); }); dataSource.sync();