[DataGrid] How to set the DataContext to a specific cell?

2 Answers 28 Views
DataGrid
Sebastien
Top achievements
Rank 1
Sebastien asked on 26 Apr 2022, 07:50 PM
Hi,

My goal is to create dynamically columns. Columns are added via a timer event. I have access to the data before to set the DataContext.

I found that the DataGrid has the method HitTestService.CellInfoFromPoint/RowItemFromPoint, but it requires a point.

Alternatively, is there a way that I could set the DataContext in another way?
Sebastien
Top achievements
Rank 1
commented on 26 Apr 2022, 09:14 PM

In order to help, here is a sample app. 

The technic of using Loaded event of the DataTemplate did not work.

Screenshot.png is what the sample does
Expected result.png is what I would like

Thank you!

2 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 02 May 2022, 04:20 PM

Hello Sebastien,

I am not sure I completely understand the scenario - I've tested the attached app and reproduced the same result as shown in the first image - I assume it is due to different timing when the new columns are added and DataContext is set.

Could you elaborate a little bit more on the exact use case?

Regards,
Yana
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.

Sebastien
Top achievements
Rank 1
commented on 02 May 2022, 04:31 PM

Hi Yana,

The sample was provided by Lance (we know each others), he tried to find a workaround for my problem, but his solution does not work.

As for now, I used ExpendoObject, but I have to reset the grid each time. This is not optimal but it kind of work. You will see in the attached video what I want to do. The data is heavy horizontally.

Thank you
Sébastien
0
Yana
Telerik team
answered on 06 May 2022, 01:50 PM

Hello Sebastien,

I reviewed the provided information and the video and I am afraid I couldn't come up with another solution rather than resetting the DataGrid.  I understand this is not optimal, still the scenario is quite specific.

I am sorry I didn't manage to help in this case.

Regards,
Yana
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
DataGrid
Asked by
Sebastien
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or