How Do I force a postback to controller when combo item selected

2 posts, 0 answers
  1. Acadia
    Acadia avatar
    204 posts
    Member since:
    May 2005

    Posted 25 Jan Link to this post

    hello,

    I am new to the Kendo UI so I really need some help.  I'm sure this is simple for those knowledgable, but I have tried everything.

    I have a kendo combobox on my index.cshtml view.  The combo is filling correctly.  It is bound to a list within my model.

    What I need to do is make it post back to my index controller when a user makes a selection.  I have spent hours reading the forums and other online blogs and cannot seem to find an example like mine using combobox.

    Here is my combobox:

     .Content(@<text>
                <div style="padding:5px">
                    @(Html.Kendo().ComboBox()
                    .Name("PaystubsCombo")
                    .Placeholder("Select a Paystub")
                    .BindTo(Model.PaystubsAvailable)
                    .DataTextField("WedDDDisplay") 
                    .DataValueField("WedValue")
                   
                    )
                </div>
        </text>)
    )

     

    Thanks for the help in advance!

  2. Veselin Tsvetanov
    Admin
    Veselin Tsvetanov avatar
    550 posts

    Posted 27 Jan Link to this post

    Hello Justin,

    To initiate an AJAX call to the controller, when user changes the selection in the ComboBox, you could handle the change event of the widget and initiate your custom ajax call:
    function onItemChange(e) {
        $.ajax({
            url: '@Url.Action("Post", "Home")',
            type: 'GET',
            dataType: 'json',
            data: { id: e.sender.value() },
            success: function (data) {
                // Your success handler here
                alert("Returned ID: " + data.returnedId);
            }
        });
    }

    Attached you will find a sample project, demonstrating the above implementation.

    Regards,
    Veselin Tsvetanov
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 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