Hi
version 2015.1.515
I try use dropdownlist with virtual in kendo grid, edit mode - InCellEdit. Works fine for select new value, but if i open cell for edit, dropdown show default value (option label). Autobind is set to false.
With version 2015.1.515 and Autobind = false, works with litle hack. (on grid Edit event after 500ms i call dropdown.datasource.read()).
function
OnGridEdit()
{
setTimeout(
function
() {
var
artDrop = $(
"#ArticleId"
).data(
"kendoDropDownList"
);
if
(artDrop)
{
artDrop.dataSource.read();
}
}, 300);
}
But with version 2015.1.515 not work anymore, still reset value to default. I found another hack how this work, but i'm not happy with it. On edit event after some ms set value to dropdown from grid model.
Is another way to use dropdownlist with virtual in grid with incell edit? Thanks
01.
function
OnGridEdit(e)
02.
{
03.
04.
setTimeout(
function
() {
05.
var
artDrop = $(
"#ArticleId"
).data(
"kendoDropDownList"
);
06.
if
(artDrop)
07.
{
08.
artDrop.value(e.model.ArticleId);
09.
}
10.
}, 300);
11.
12.
}
13.
14.
Editor template for grid
01.
<%@ Control Language=
"C#"
Inherits=
"System.Web.Mvc.ViewUserControl<int?>"
%>
02.
03.
<script type=
"text/javascript"
>
04.
function ArticlesReadPostData() {
05.
return
{
06.
__RequestVerificationToken: $(
'[name=__RequestVerificationToken]'
).val(),
07.
onlyNotStorable:
false
,
08.
excludeRound:
true
09.
}
10.
}
11.
</script>
12.
13.
<%=
14.
Html.Kendo().DropDownList()
15.
.HtmlAttributes(
new
{ style=
"width:100%;"
})
16.
.ValuePrimitive(
true
)
17.
.MinLength(1)
18.
.Name(
"ArticleId"
)
// Name of the widget
19.
.DataTextField(
"ArticleCode"
)
20.
.DataValueField(
"ArticleId"
)
21.
.OptionLabel(
new
{ ArticleId =
""
, ArticleCode = LanguageResources.Resource.L_ChooseFromOptions })
22.
.Filter(FilterType.StartsWith)
23.
.AutoBind(
false
)
24.
.DataSource(source =>
25.
{
26.
source.Custom()
27.
.ServerFiltering(
true
)
28.
.ServerSorting(
true
)
29.
.Sort(srt => srt.Add(
"ArticleCode"
))
30.
.ServerPaging(
true
)
31.
.PageSize(31)
32.
.Type(
"aspnetmvc-ajax"
)
//Set this type if you want to use DataSourceRequest and ToDataSourceResult instances
33.
.Transport(transport =>
34.
{
35.
36.
transport.Read(rd =>
37.
{
38.
rd.Data(
"ArticlesReadPostData"
);
39.
rd.Type(HttpVerbs.Post);
40.
rd.Action(
"ReadArticlesFilteredCombobox"
,
"Article"
);
41.
});
42.
})
43.
.Schema(schema =>
44.
{
45.
schema.Data(
"Data"
)
//define the [data](http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-schema.data) option
46.
.Total(
"Total"
);
//define the [total](http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-schema.total) option
47.
48.
});
49.
})
50.
.Virtual(v => v.ValueMapper(
"function(e) { return ArticleValueMapper.call(this, e, ArticlesReadPostData()) }"
))
51.
52.
53.
%>