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

Multiple DropDownList MVVM with same DataSource

7 Answers 570 Views
DropDownList
This is a migrated thread and some comments may be shown as answers.
Neeraj
Top achievements
Rank 1
Veteran
Neeraj asked on 04 Jun 2018, 08:51 AM

Hello, have Multiple DropDownList MVVM with same/shared DataSource. The problem is when selected a value from the earlier selected values get reset. 
        I tried having multiple  as that even  works. I also tried in this https://docs.telerik.com/kendo-ui/controls/editors/multiselect/troubleshoot/troubleshooting#selected-item-is-lost-when-bound-to-shared-datasource 
         That also   Here is my code.

Inside Template:

<script id="SegmentSelectionGridRowTemplate" type="text/x-kendo-template" class="AirPricingDivScript">
    <tr>
        <td>
            <label>#= data.SegmentDetailsToDisplay #</label>
 
        </td>
        <td>
            <input  data-role="dropdownlist" data-value-primitive="true" data-text-field="AirRequestToDisplay" data-value-field="ReservationRequestItemId"
                   data-bind="value: ReservationRequestItemID, source: SegList"  />
        </td>
    </tr>
</script>

 

<div data-role="grid" id="SegmentSelectionGrid" class="margin-top" style="margin-left: 0px;" data-bind="source: AirPNRViewModel.Segments" data-toolbar="<div><i class='fa fa-plane' aria-hidden='true'></i> <b>Flight Segment(s)</b> </div>"
             data-columns='[
                         { "field": "PNRSegment", "title": "PNR Segment","width":"220"},
                     {"field": "RequestRoute","title":"Request Route","width":"80"}]'
             data-row-template="SegmentSelectionGridRowTemplate"></div>

 

Script:

var viewModel = kendo.observable({
SegList :[{"ReservationRequestItemId":1716,"AirRequestToDisplay":"SIN-LAD 03-06-2018"},{"ReservationRequestItemId":1716,"AirRequestToDisplay":"LAD-SIN 13-06-2018"},{"ReservationRequestItemId":1716,"AirRequestToDisplay":"SIN-BKK 02-06-2018"}],
AirPNRViewModel:{
 Segments: [
{"ReservationRequestItemID":0,"SegmentDetailsToDisplay":"TG  410"},
{"ReservationRequestItemID":0,"SegmentDetailsToDisplay":"ET  619"}
 
 ]

 

7 Answers, 1 is accepted

Sort by
0
Bozhidar
Telerik team
answered on 05 Jun 2018, 01:19 PM
Hello,

I tried the described setup and it seems to work as expected on my end. Could you specify what the exact issue is? Perhaps share a screen capture of the problem?

Regards,
Bozhidar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Neeraj
Top achievements
Rank 1
Veteran
answered on 06 Jun 2018, 05:01 AM
Hello, Please see attached file for . Open file in that zip.  The Exact issue is when select value from dropdown other values get as shown in  attached.  I also tried giving name to data-value-field but result is same
0
Neeraj
Top achievements
Rank 1
Veteran
answered on 06 Jun 2018, 05:02 AM
Here is attachment
0
Bozhidar
Telerik team
answered on 06 Jun 2018, 05:48 AM
Hello,

I've isolated a sample in our online dojo, and it seems to be working as expected. Could you give it a go, and see if it's working on your side as well:
https://dojo.telerik.com/ujiGukEv


Regards,
Bozhidar
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Luciano Kaesemodel
Top achievements
Rank 1
answered on 25 Jan 2019, 05:50 PM

Hello,
I have a similar problem. In a grid, I'm trying to put two dropdownlist columns with the same data source, when I select a value in one dropdown it's replicating in the other. follows Dojo with example:
https://dojo.telerik.com/@machado/OvIqAjuD

thank you.

0
Bozhidar
Telerik team
answered on 29 Jan 2019, 01:24 PM
Hi,

The problem here is that in both templates the value of the DropDownList is bound to the Id field of the Product. To fix this just include a separate template for the second column, bound to the same datasource, but with the correct value-binding. Here's the modified and working dojo sample:
https://dojo.telerik.com/AlUGEzeb

Regards,
Bozhidar
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Luciano Kaesemodel
Top achievements
Rank 1
answered on 11 Feb 2019, 10:48 AM
Thank you Bozhidar, problem solved.
Tags
DropDownList
Asked by
Neeraj
Top achievements
Rank 1
Veteran
Answers by
Bozhidar
Telerik team
Neeraj
Top achievements
Rank 1
Veteran
Luciano Kaesemodel
Top achievements
Rank 1
Share this question
or