Hello,
I'm trying to accomplish the following: I need an ajax enabled grid (declared with wrappers); the entities of the grid (let's say of type DocumentData) have a reference to another entity (that would be Country) .
Now, when in view mode, the grid should display the Description of the Country: this I accomplish by using the ClientTemplate of the BoundColumn.
When in edit mode, the grid should display a combobox; this combobox must be bound to the action of a controller: this gives us also filtering.
Filtering Country and saving DocumentData with the new selected data works perfect.
The problem appears when we try to edit again: when switching the row to edit mode, the combox does not display the text (the Description property of the Country), but the Id; even so, if we delete the number in the combox, the filtering works again, and also the updating.
Below the code :
And, the editor template:
Attached you can find some pictures of the grid in view mode and edit mode.
Do you have any idea why this might happen ?
Thank you,
Bogdan
I'm trying to accomplish the following: I need an ajax enabled grid (declared with wrappers); the entities of the grid (let's say of type DocumentData) have a reference to another entity (that would be Country) .
Now, when in view mode, the grid should display the Description of the Country: this I accomplish by using the ClientTemplate of the BoundColumn.
When in edit mode, the grid should display a combobox; this combobox must be bound to the action of a controller: this gives us also filtering.
Filtering Country and saving DocumentData with the new selected data works perfect.
The problem appears when we try to edit again: when switching the row to edit mode, the combox does not display the text (the Description property of the Country), but the Id; even so, if we delete the number in the combox, the filtering works again, and also the updating.
Below the code :
@{
Html.Kendo()
.Grid<
Teamnet.eViza.Model.Entities.App.DocumentData
>()
.Name("gridDocumentData")
.Columns(columns =>
{
columns.Bound(c => c.Id);
columns.Bound(c => c.IssuedByAuthority);
columns.Bound(c => c.IssuedCountry)
.ClientTemplate("#=(IssuedCountry == null) ? '' : IssuedCountry.roDescription #")
.EditorTemplateName("NomLookup");
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(200);
})
.DataSource(dataSource =>
{
dataSource.Ajax()
.CrudWithQueryAndDefaultCommands(
new Teamnet.eViza.Business.Queries.AllEntitiesOfTypeName(typeof(Teamnet.eViza.Model.Entities.App.DocumentData)),
"DocumentData")
.AutomaticRefreshed();
dataSource.Ajax()
.Model(model => model.Id(a => a.Id));
dataSource.Ajax().PageSize(10);
})
.ToolBar(toolbar => toolbar.Create())
.Editable(editable => editable.Mode(GridEditMode.InLine))
.AutoBind(true)
.Pageable()
.Filterable()
.Sortable()
.Render();
}
And, the editor template:
@model Teamnet.eViza.Model.Entities.BaseNom
@(Html.Kendo().ComboBoxFor(a => a)
.DataTextField("roDescription")
.DataValueField("Id")
.Filter(FilterType.StartsWith)
.HighlightFirst(true)
.MinLength(1)
.DataSource(dataSource =>
dataSource.Read(read =>
read.Action("Read", "NomComboBox", new { nomType = Teamnet.eViza.WebCommon.Utils.TypeUtils.FullNameWithAssembly(ViewData.ModelMetadata.ModelType) })
).ServerFiltering(true))
.SelectedIndex(0)
)
Attached you can find some pictures of the grid in view mode and edit mode.
Do you have any idea why this might happen ?
Thank you,
Bogdan