Copy one multiselect values to another multiselect

7 posts, 0 answers
  1. crazy05
    crazy05 avatar
    72 posts
    Member since:
    Sep 2014

    Posted 18 Oct 2014 Link to this post

    Hi,

    I have one multiselect in cshtml page. When I click on button in cshtml page, I am showing Kendo Window. In kendo window, there is one more multi select and OK, Cancel buttons.

    If user clicks on OK, I am calling controller and passing values of multiselect and doing the required operation.

    I want to display the same values in multiselect in cshtml page. How can I do this ? Here is my code.

    $("#okay").kendoButton({
                click: function () {               
                    var rowID = $("#selectedValues").val();
                    data = { 'rows': rowID };               
                    $.ajax({
                        type: "POST",
                        url: "Rows" + window.location.search,
                        data: data,
                        traditional: true,
                        dataType: "json",
                        success: function (result) {                       
                            $("#Dialog").data("kendoWindow").close();
                            return true;
                        },
                        error: function () {
                            alert("An Error Occured. Please Cancel and Try Again!");
                            return false;
                        }
                    });
                }
            });
  2. crazy05
    crazy05 avatar
    72 posts
    Member since:
    Sep 2014

    Posted 19 Oct 2014 in reply to crazy05 Link to this post

    Hi,

    On document.ready function, multiselect in main cshtml page is null. I am not binding any datasource.

    How can I do this ?
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. crazy05
    crazy05 avatar
    72 posts
    Member since:
    Sep 2014

    Posted 20 Oct 2014 Link to this post

    Any help ?
  5. crazy05
    crazy05 avatar
    72 posts
    Member since:
    Sep 2014

    Posted 21 Oct 2014 Link to this post

    var multiselect = $("#multiselect1").data("kendoMultiSelect");
     $("#multiselect2").data("kendoMultiSelect").setDataSource(multiselect.dataSource);
  6. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 22 Oct 2014 Link to this post

    Hi Ram,

    You can use the MultiSelect and it's DataSource API to get the value from the second widget and set it as value to the first MultiSelect inside the "success" event handler of the custom "ajax" request. For convenience I created small demo of copying values and dataSource from one MultiSelect to another which you can use as baseline to achieve the desired behavior:


    Regards,
    Vladimir Iliev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  7. crazy05
    crazy05 avatar
    72 posts
    Member since:
    Sep 2014

    Posted 22 Oct 2014 in reply to Vladimir Iliev Link to this post

    H
    Vladimir Iliev said:
    Copy values from one MultiSelect to another



    This code snippet is not loading.
  8. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 23 Oct 2014 Link to this post

    Hi Ram,

    The previous example is accessible on our side, however for your convenience I uploaded the example to jsBin as well:

    Regards,
    Vladimir Iliev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
UI for ASP.NET MVC is VS 2017 Ready