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

DropDownList with Virtual in Grid

6 Answers 206 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Erich
Top achievements
Rank 1
Erich asked on 29 May 2015, 07:56 AM

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. %>

6 Answers, 1 is accepted

Sort by
0
Erich
Top achievements
Rank 1
answered on 29 May 2015, 08:00 AM

Sorry i wrote wrong wersion, not work anymore with version 2015.1.528

 

Thanks

0
Georgi Krustev
Telerik team
answered on 02 Jun 2015, 12:06 PM
Hello Ján,

After Q1 2015 SP2 (2015.1.429) release, we introduced an enhancement related to the MVVM value binding and its behavior when widget has an autoBind=false option. The idea was to avoid calling the widget value method (as it will trigger datasource binding) and just update the selected text and value. This was changed a little bit in the 2015.1.528 (#820) and now the widget will force the binding when value is of primitive type. I suppose that you are seeing this behavior.

I prepared a simple test demo that uses the latest internal build of Kendo UI. Could you review the code and if possible modify it to reproduce the erroneous behavior? This will help us to narrow the problem down faster.

Regards,
Georgi Krustev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Erich
Top achievements
Rank 1
answered on 04 Jun 2015, 11:06 AM

Thanks,

 

I checked yours project (change edit mode to in cell) and works great. I must compare with my project (in depth), what is different.

Thanks

0
Erich
Top achievements
Rank 1
answered on 12 Jun 2015, 08:54 PM
I figure out what was a problem. In editor template i had Kendo.DropDownList(), but must be Kendo().DropDownListFor(m => m) and this works fine

Thanks
0
Erich
Top achievements
Rank 1
answered on 12 Jun 2015, 10:22 PM

I found another situation when Incell edit not select selected value, I cannot upload yout project, my connection is terrible and upload end with timeout error.

 Only what i changet in yours project was, grid edit mode -> InCell, 

DropDownListLookUp editor template added   .OptionLabel(new { ProductID = "", ProductName = "sel" })

 

Thanks

0
Georgi Krustev
Telerik team
answered on 16 Jun 2015, 12:15 PM
Hello Ján,

You are absolutely correct. The widget will not select the correct item, when optionLabel is defined. We will address this immediately and the next internal build will include the fix.
I updated your Telerik points because of the report.

Regards,
Georgi Krustev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
DropDownList
Asked by
Erich
Top achievements
Rank 1
Answers by
Erich
Top achievements
Rank 1
Georgi Krustev
Telerik team
Share this question
or