Get checked items upon form submission

2 posts, 0 answers
  1. Ryan
    Ryan avatar
    3 posts
    Member since:
    Oct 2011

    Posted 10 Jul 2018 Link to this post

    Hello,

    How do we go about getting the checked items when we submit a form containing the DropDownTree?  Specifically, I'd like to get a list of checked Id values from the TreeViewItemModel.

    Thanks

  2. Plamen
    Admin
    Plamen avatar
    2958 posts

    Posted 12 Jul 2018 Link to this post

    Hi,

    The HTML <form> element would submit to the server the values of the <input> elements it contains. In the scenario when we have multiple checked items passing getting them from a value of an input in not quite flexible so in such case we would rather recommend use and ajax post request and pass the desired information in the data. Here is sample code that worked at my side:
    <script>
        $("#btnSave").on("click", function (e) {
            var dropdowntree= $('#dropdowntree').data('kendoDropDownTree');
            var dDTreeItems = JSON.parse(JSON.stringify(dropdowntree.value()));
            debugger
            var data = {
                DDTreeItems: dDTreeItems
            };
     
            $.ajax('/Home/Save', {
                type: 'POST',
                data: data,
                dataType: "json"
            }).done(function () {
                alert('done');
            });
        });
     
    </script>


    If you have further questions please let me know.

    Regards,
    Plamen
    Progress Telerik
    Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top