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

Defining combobox with events in popup template?

1 Answer 232 Views
Templates
This is a migrated thread and some comments may be shown as answers.
tom
Top achievements
Rank 1
tom asked on 08 Nov 2012, 10:42 AM
Hi,

I'm currently struggling to define a combobox in a grid popup template. The combobox should react on its own change event.

Is this possible and can somebody give me an example on how to achieve this?

sincerely,
tom

1 Answer, 1 is accepted

Sort by
0
Jeremy Cook
Top achievements
Rank 1
answered on 29 Nov 2012, 05:56 AM

Here is a copy of my template i am using for a pop up in a grid;

     <script id="popup_editor" type="text/x-kendo-template">
<div class="k-edit-label">
    <label for="ItemID">Item</label>
</div>
<input name="ItemID"
    data-bind="value:ItemID"
    data-value-field="ItemID"
    data-text-field="ItemName"
    data-source="itemListDataSource"
    data-role="dropdownlist"
    data-auto-bind="false" />
    </script>

In the Edit event on the grid get the dropdownlist and bind to the change event.

$("#divid").kendoGrid({
               toolbar: [{ name: "create"}],
               dataSource: someDataSource,
               pageable: false,
               scrollable: false,
               editable: {
                   mode: "popup",
                   template: $("#popup_editor").html()
               },
               edit: function (e) {
                   $("#editor").kendoEditor();
                   if (e.model.id == "") {
                       $('.k-window').find('.k-window-title').html("Add New");
                   }
                   else {
                       $('.k-window').find('.k-window-title').html("Edit");
                   }
                 
                   var itemDropListContol = $(e.container).find("input[name='ItemID']");
                   itemDropListContol.data("kendoDropDownList").bind("change", function (f) {
                       // do stuff
                   });
               },
 
           });


Tags
Templates
Asked by
tom
Top achievements
Rank 1
Answers by
Jeremy Cook
Top achievements
Rank 1
Share this question
or