Unplanned
Last Updated: 09 Oct 2024 19:16 by Scott
Patrick
Created on: 29 Nov 2012 11:36
Category: Data Source
Type: Feature Request
90
Support composite keys in the DataSource ID property
At the moment, the DataSource only uses one field for its ID property (if you enter several, then only one is used, apparently).  This doesn't reflect reality, in that in many cases (where one record is a child of another), the key field for a database table is a composite (from 2 or more fields).  
The existing situation causes problems in inline editing of the KendoUI grid, because default values need to be set for foreign key fields, but if these are set to a valid value, then spurious calls to the Inline_Create method occur because the DataSource treats the record as a new record when it is not.
In any case, allowing multiple fields would simply reflect reality.
17 comments
Scott
Posted on: 09 Oct 2024 19:16

Another $0.02

Yes, there are multiple approaches that can get the work done. It's all a matter of complexity.

Your tree might contain data of different types with potentially colliding IDs. Maybe root nodes are one type, child nodes are another.

When I needed a composite key, I got lucky. The two types of nodes don't have overlapping IDs. On the server side, I do have to lookup the ID in two tables to determine the node's type. One table is small-ish, so it's not a big deal.

I would suggest files and folders as an example, but using the filesystem's fully qualified path would make for unique IDs.

ADMIN
Angel Petrov
Posted on: 13 Jul 2022 13:47

Hi,

Thank you for sharing the idea with the community. Indeed other users may benefit from it.

Regards,
Angel Petrov
Progress Telerik

The Premier Dev Conference is back! 

Coming to you live from Progress360 in-person or on your own time, DevReach for all. Register Today.


John
Posted on: 07 Jul 2022 13:13
our datasources were coming from views.  I did the same and made a field labelled "compositekey" that concatenated the other fields with underscores.
Scott
Posted on: 06 Jul 2022 17:44

For what it is worth, we have a workaround that works for us. I am sure other DataSource users have stumbled across the same solution, but just in case...

  • Create a data transfer object ("DTO") that is passed to the page as the model for the view.
  • The DTO should declare a read-only string property named Id.
  • The value of the Id property should be the primary key for the entity being displayed in the grid.
  • If the entity has a multi-column primary key, either:
    • Declare an artificial single-property primary key (e.g., in SQL Server a table with a uniqueidentifier as the primary key) and return the string representation of that property as the value of the Id property,
      OR
    • Implement the Id property to return a string concatenation of the values of the primary key properties delimited with the pipe "|" character.

Since we were already using DTO's anyway, this workaround was a good fit for us. We declared an abstract base class that all of our DTO classes inherit from. The base class declares a public virtual string Id property that only has a getter that returns string.Empty. Descendant DTO classes must override the Id property and return the primary key property value converted to a string (either the single-property PK or the multi-property PK concatenated with pipe "|" characters).

ADMIN
Angel Petrov
Posted on: 21 Jun 2022 10:42

Hi,

There are corner cases when it comes to a composite keys. That said satisfying all conditions may be difficult. When having a particular problem I would recommend opening a formal support ticket and posting the problematic code there so it can be revised and further assistance on the specific matter can provided.

Regards,
Angel Petrov
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/.

John
Posted on: 14 Jun 2022 15:49

This really needs to be looked at.  We implemented a method to pass two values back to the controller when editing but when you cancel edit, the grid puts the wrong record back.

 

ADMIN
Nikolay
Posted on: 14 Jan 2022 09:41

Hello Scott,

Thank you for the feedback.

I have raised this matter to the Dev team and they are working on it. I will follow up once I have more information.

Regards,
Nikolay
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/.

Scott
Posted on: 08 Jan 2022 04:09

Surprised and very disappointed that multi-column primary keys are not supported. This severely limits the usefulness of the DataSource, and since the DataSource is at the heart of--well, just about EVERYTHING in KendoUI--we will probably start looking at other UI frameworks when our license comes up for renewal.

ADMIN
Nikolay
Posted on: 02 Jul 2020 09:46

Hello Kevin,

This feature is currently not planned for a release. However, once it gets placed in the RoadMap it will receive a status Planned and later on Completed when it is live.

Addityioanlly, you can click on the Follow button to receive automatic updates about status changes.

Regards,
Nikolay
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
kevin
Posted on: 25 Jun 2020 19:00
How can I track the release of this feature request? 
Asiri Dissa
Posted on: 03 Jun 2020 02:35
Still not in place?
This is a valuable addition to the framework. Hope you are working on this.
ADMIN
Nikolay
Posted on: 24 Dec 2019 12:53

Hi Alexander,

Thank you for bringing this feature request back to our attention. I can definitely see the value in it so I uplifted its priority and it will be reviewed by the Product Management for future planning and implementation.

    Regards,
    Nikolay
    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.
    Alexander
    Posted on: 18 Dec 2019 02:26

    I use Kendo with a SQL data warehouse with a normalised star schema design in order to achieve scalable performance and parallel operation. This uses large sets of fields as a primary key so the suggested workaround of creating a psuedo key by concatenating just wouldn't be feasible.

    The only workaround for this design is to include a separate ID field for use only with Kendo. This destroys performance and has forced us to avoid using Kendo for CRUD operations whenever possible.

    I think it's about time composite keys were supported so this can be a true option for use with enterprise grade applications.

    Stephen
    Posted on: 02 Apr 2019 14:12
    I am surprised that a professional and enterprise-strength toolset like this product still does not support composite keys after all these years. Let's make it happen! :)
    Steve
    Posted on: 19 Feb 2018 17:22
    I worked around this with a pseudo key as suggested in this post. https://www.telerik.com/forums/composite-datakey-in-kendo-ui-mvc#JlhcEtSyAEqMWaW6TjnDKQ
    Patrick
    Posted on: 23 Aug 2014 19:45
    I have used the following workaround to solve this. 
    Usually I have to use buddy or ViewModel classes in the grid, rather than the raw entity framework (or other) classes from the database itself, because the raw classes usually have circular object graphs (because they have parent child relationship fields). 
    
    In the code to create buddy/viewmodel classes from the raw classes, I populate an extra field that I've added to the buddy classes, IDForKendoTemplate, and I give this a unique value (i.e. 1, 2, 3, sequentially) for each object that is converted.  I can then use that field as the ID for kendoUI grids, and to identify parent grids uniquely in templates.
    Kevin
    Posted on: 15 May 2013 21:53
    I ran into this too.  A UI framework shouldn't really force us to have our data stored in a certain way to be effective.