This is a migrated thread and some comments may be shown as answers.

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

1 Answer 326 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Acadia
Top achievements
Rank 1
Iron
Acadia asked on 25 Jan 2017, 05:10 PM

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!

1 Answer, 1 is accepted

Sort by
0
Veselin Tsvetanov
Telerik team
answered on 27 Jan 2017, 01:46 PM
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.
Tags
ComboBox
Asked by
Acadia
Top achievements
Rank 1
Iron
Answers by
Veselin Tsvetanov
Telerik team
Share this question
or