4
I have a Kendo grid and I’m creating a template for editing the data presented on the grid, but I’m having problems with the code below...
This is part of the code of my template:
<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 fill the dropdownlist
with the necessary 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 it is all right, and the code is working perfectly bringing the value that is on the grid, but the problem is that even with the autoBind
receiving the value false
the dropdownlist
is coming with the first option always selected (in case masculino
), that is, when the data of a person of sex feminino
is edited, the dropdownlist
shows by default the value that came from the grid (feminino
), but when it is expanded the two values selected are displayed. How can I resolve this?
Look what I’m talking about:
I searched the documentation and I couldn’t find anything on how to disable this, however, as an alternative, you can set a default value using the property
value
, see this example.– stderr
'Cause you’re my friend, thank you very much for your commitment to help me, I haven’t found anything yet either. The problem is that in my case the
kendoDropDownList
is created within thex-kendo-template
and I can’t create such an object in javascript to be placed there, just theDataSource
. I’m studying a little of thisx-kendo-template
, it is not possible that there is no property that can do this.– Jedaias Rodrigues
Another thing, is that actually I would not like to come with a default value marked, but on the contrary, I would like only the value that is on the grid to be marked.
– Jedaias Rodrigues
Any chance you can play this in a demo?
– DontVoteMeDown