Find and change the selected item in a dropdown list in a grid row.

1 Answer 276 Views
DropDownList Grid
Keith
Top achievements
Rank 1
Iron
Iron
Keith asked on 22 Sep 2023, 09:22 PM | edited on 22 Sep 2023, 09:24 PM


@model DetailSelectionViewModel

@(Html.Kendo().DropDownListFor(m => m)
        .DataValueField("Id")
        .DataTextField("Name")
        .Value(Model.Selected)
        .Events(e =>
        {
            e.Select("SelectionDropDownItemSelected");
            e.DataBound("SelectionDropDownDataBound");
        })
        .DataSource(dataSource => dataSource
            .Read(read => read.Action("GetDetailList", "DataWorksheet"))
        )
)

Above is the drop down that I have embedded within a detail grid.  When a value is changed in the master grid I need to traverse through all the detail rows and change the selected item in the dropdown list in each row.

So I successfully traverse the dataitems bound to the detailgrid. The dropdown appears to be changed until you actually click on the dropdown list and the dropdown appears with the selecteditem still being the item that was selected when the grid was originally rendered. When I click on the dropdown the Read Action occurs and the data is retrieved and the dropdown is bound, but the selected value isnt set to the new value desired.

Thinking that I can traverse the dataitems and set the values there. Think I need to traverse the datagrid itself and find the dropdown list in each row and programmatically choose the selected value.  I see no sample code to one traverse the datagrid that is a child when parent changed. I see no sample code to find the dropdown list in a datagrid row.

My logic starts when the datasource change event occurs for the parent grid.

Can anyone assist please. These tasks cant be that uncommon.

1 Answer, 1 is accepted

Sort by
0
Anton Mironov
Telerik team
answered on 27 Sep 2023, 12:06 PM

Hello Keith,

Thank you for the code snippet and the details provided.

In order to achieve the desired behavior, I would recommend saving the change in the child DropDownList. This could be achieved by:

I hope this information helps. Give a try to the approaches above and if further assistance is needed  -send me a runnable sample of your application, back in this thread and I will try my best to achieve the desired result.

Kind Regards,
Anton Mironov
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages. If you're new to the Telerik family, be sure to check out our getting started resources, as well as the only REPL playground for creating, saving, running, and sharing server-side code.

Tags
DropDownList Grid
Asked by
Keith
Top achievements
Rank 1
Iron
Iron
Answers by
Anton Mironov
Telerik team
Share this question
or