How to disable default value in kendo dropdownlist?

4

I have a kendo grid and I'm creating a template for editing the grid data, but I'm having problems with the code below ... Home This is part of my template code:

<script id="popup_editor" type="text/x-kendo-template">

<div class="k-edit-label">
   <label for="Sexo">Sexo</label>
</div>

<input name="Sexo"
   data-bind="value:Sexo"
   data-value-field="sexoValue"
   data-text-field="sexoName"
   data-source="sexoDropDownDataSource"
   data-role="dropdownlist" />

</script>

This is my script to populate dropdownlist with the required data:

sexoDropDownDataSource = new kendo.data.DataSource({
                autoBind: false,
                dataTextField: "sexoName",
                dataValueField: "sexoValue",
                data: [
                    { sexoName: "Masculino", sexoValue: "M" },
                    { sexoName: "Feminino", sexoValue: "F" }
                ]
            });

As you can see, everything is fine, and the code is working perfectly bringing the value on the grid, but the problem is that even with autoBind getting value false dropdownlist is coming with the first always selected (in masculino ), that is, when the data of a person of gender feminino is edited, dropdownlist shows the value that came from the grid ( feminino ), but when it is the two selected values are displayed. How can I resolve this?

Look what I'm talking about:

    
asked by anonymous 01.06.2015 / 15:38

1 answer

-1

Try to use the dataBound event in your dropdownlist to let the value that comes from the grid be selected. Maybe this link can help you:

link

Example:

var sexoDataDropDown = $("#sexoDropDownDataSource").data("kendoDropDownList");
sexoDataDropDown.value(Masculino);
    
09.06.2015 / 15:37