Different dropdown dataset for each row in grid

1 Answer 30 Views
DropDownList Grid
Balazs
Top achievements
Rank 1
Balazs asked on 20 Feb 2024, 12:07 PM | edited on 20 Feb 2024, 12:48 PM

Hello!

I'm working with a grid that contains several Kendo dropdown lists. The data for these dropdowns relies on certain values within the grid, which can vary for each row. Currently, the dataset from the last row is being applied to all dropdowns in previous rows. How can I ensure that each dropdown in a row uses its own unique dataset based on the values specific to that row?

Thanks,

Balazs

 

UPDATE:

The functionality is operating correctly as intended. The issue only occurred on my end.

1 Answer, 1 is accepted

Sort by
0
Martin
Telerik team
answered on 23 Feb 2024, 06:44 AM

Hi Balazs,

In case each Grid row DropDownList should have its own data source, the dropdown arrays must be presented in the Grid data.

 public gridData: Product[] = [
    {
      ProductID: 1,
      ProductName: 'Chai',
      ddl_data: [1, 2, 3],
    },
    {
      ProductID: 2,
      ProductName: 'Chang',
      ddl_data: [4, 5, 6],
    }]

Inside the kendoGridCellTemplate of the Grid (in case the DropDownList appears in cell template), use the dataItem field provided by the directive and set the DropDownList data:

<kendo-grid-column field="Category.CategoryName" title="Category">
      <ng-template kendoGridCellTemplate let-dataItem="dataItem">
              <kendo-dropdownlist [data]="dataItem.ddl_data"></kendo-dropdownlist>
        </ng-template>
</kendo-grid-column>

Here is an example:

https://stackblitz.com/edit/angular-hhy6uw

If kendoGridEditTemplate also provides dataItem field:

https://www.telerik.com/kendo-angular-ui/components/grid/api/EditTemplateDirective/

In case the DropDownList data depends on another control, please check the following article for more details on how to implement cascading DropDownLists:

https://www.telerik.com/kendo-angular-ui/components/knowledge-base/cascading-dropdowns-grid/

Regards,
Martin
Progress Telerik

Stay tuned by visiting our public roadmap and feedback portal pages! Or perhaps, if you are new to our Kendo family, check out our getting started resources
Tags
DropDownList Grid
Asked by
Balazs
Top achievements
Rank 1
Answers by
Martin
Telerik team
Share this question
or