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

virtual.valueMapper() never be called in one of the Dropdownlist

3 Answers 27 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Daochuen
Top achievements
Rank 1
Iron
Veteran
Iron
Daochuen asked on 30 Mar 2021, 04:16 PM

Hello,

In our MVC project we used two kendo dropdownlist widgets. Since data may become huge we implemented virtual.valueMapper() to get job done. Both dropdownlist worked as expected but when I debug code and found one of valueMapper() never be called. Those two dropdownlist had exactly same setting. Why they are function differently? I am so curious the reason. Could someone explain this? Below are the code. Thanks in advance.

    <div class="col-lg-3 col-md-3 col-sm-3">
        @(Html.Kendo().DropDownListFor(model => model.FIELD1)
                                                .DataTextField("Display")
                                                  .DataValueField("Value")
                                                  .Filter("contains")
                                                  .DataSource(source =>
                                                  {
                                                      source.Custom()
                                                          .ServerFiltering(true)
                                                          .ServerPaging(true)
                                                          .PageSize(80)
                                                          .Type("aspnetmvc-ajax")
                                                          .Transport(transport =>
                                                          {
                                                              transport.Read("GetField1Data", "Editor");
                                                          })
                                                          .Schema(schema => schema.Data("Data").Total("Total"))
                                                          ;
                                                  })                                       
                                                 .Virtual(v => v.ItemHeight(26).ValueMapper("valueMapperField1"))//<- never be called 
                                                   
            )
    </div>
    <div class="col-lg-3 col-md-3 col-sm-3">
        @(Html.Kendo().DropDownListFor(model => model.FIELD2)
                                                  .DataTextField("Display")
                                                  .DataValueField("Value")
                                                  .Filter("contains")
                                                  .DataSource(source =>
                                                  {
                                                      source.Custom()
                                                          .ServerFiltering(true)
                                                          .ServerPaging(true)
                                                          .PageSize(80)
                                                          .Type("aspnetmvc-ajax")
                                                          .Transport(transport =>
                                                          {
                                                              transport.Read("GetField2Data", "Editor");
                                                          })
                                                          .Schema(schema => schema.Data("Data").Total("Total"))
                                                          ;
                                                  })                                           
                                                 .Virtual(v => v.ItemHeight(26).ValueMapper("valueMapperField2")) //<- call valueMapperField2 function correctly.                                              
            )

    </div>

3 Answers, 1 is accepted

Sort by
0
Accepted
Ivan Danchev
Telerik team
answered on 02 Apr 2021, 01:10 PM

Hello Daochuen,

I've tested the scenario you described and at my end both valueMapper functions are called as expected. I've attached a sample project.

Could you give it a try at your end and modify it accordingly to demonstrate the issue, in case I am missing something with regard to reproducing it?

Regards,
Ivan Danchev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Daochuen
Top achievements
Rank 1
Iron
Veteran
Iron
answered on 05 Apr 2021, 02:09 PM

Thanks Ivan for your response. I tested your code and found both server side function Field1_ValueMapper() and Field2_ValueMapper() not be called. then I comment out (or delete ) those two functions. page still function correct. Why we need those ValueMapper method then?  Thanks.

0
Accepted
Ivan Danchev
Telerik team
answered on 08 Apr 2021, 08:57 AM

Hello Daochuen,

I checked and the Field1_ValueMapper and Field2_ValueMapper actions are called initially. See the attached video that demonstrates that.

The valueMapper is used only when setting the initial value (in this example item200 in the first DropDownList and item300 in the second one). You don't need a valueMapper if no initial value is set, or  if the value() API method is not used.

Regards,
Ivan Danchev
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
DropDownList
Asked by
Daochuen
Top achievements
Rank 1
Iron
Veteran
Iron
Answers by
Ivan Danchev
Telerik team
Daochuen
Top achievements
Rank 1
Iron
Veteran
Iron
Share this question
or