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

Composite DataKey in Kendo UI MVC?

6 Answers 1184 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Nick
Top achievements
Rank 1
Nick asked on 07 Jun 2012, 11:56 PM
I have a pretty basic data model that I'm trying to bind to a grid but I get stuck on the implementation on how to bind this specific object because it's primary key is a composite of two different columns. I'm using the Kendo UI MVC Beta at the moment. Any suggestions on how this is done? I haven't had much look searching so far.

My two columns I need for the Id are ContactNumber and ClientNumber. Below I have ContactNumber only so far.

Edit: Crap, I just noticed there are dedicated forums for the MVC version of Kendo UI. I don't suppose a moderator could move this for me?

@(Html.Kendo().Grid(Model)
    .Name("Grid")
        .Columns(columns =>
            {
                columns.AutoGenerate(true);
                columns.Command(command =>
                    {
                        command.Edit();
                        command.Destroy();
                    });
            })
    .ToolBar(toolbar => toolbar.Create())
    .Editable(editable => editable.Mode(GridEditMode.PopUp))
    .DataSource(dataSource => dataSource
        .Server()
        .Model(model => model.Id(p => p.ContactNumber))
            .Read(read => read.Action("Index", "ContactRep"))
            .Update(update => update.Action("Edit", "ContactRep"))
            .Create(update => update.Action("Create", "ContactRep"))
            .Destroy(update => update.Action("Delete", "ContactRep")))
    .Pageable()
    .Sortable()
    .Filterable()
    .Groupable())

6 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 11 Jun 2012, 02:38 PM
Hello Nick,

The Kendo datasource does not support composite data keys. However those should not be needed in order to implement your scenario. The data source needs the ID field only to determine new models from the existing ones. The whole model is submitted during an update and you have both fields available on the server.

All the best,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Tom
Top achievements
Rank 1
answered on 29 Jul 2012, 04:49 PM
One way to achieve this, if you really need the compound key, is to create a pseudo id field which has your concatenated/compound ids on the server side (perhaps returned as a string with pipe-separated values), which you can then feed to the grid data object - you can then reference this pseudo field when doing your CRUD operations.
0
Larry
Top achievements
Rank 1
answered on 22 Aug 2017, 12:14 AM
It there support for composite keys in the current MVC release?
0
Konstantin Dikov
Telerik team
answered on 24 Aug 2017, 12:00 PM
Hi Larry,

The DataSource is still not supporting composite keys, but you could try the suggestion with the pseudo id field from the previous post.


Best Regards,
Konstantin Dikov
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
koms
Top achievements
Rank 1
answered on 30 Jan 2019, 10:55 PM

Hi,

Can I know whether Telerik Grid View DataSource is supporting composite keys now?

Thanks

0
Konstantin Dikov
Telerik team
answered on 04 Feb 2019, 12:03 PM
Hi Kaumil,

This is still not supported, but you could give a vote for the following feature request and increase its priority:

Best Regards,
Konstantin Dikov
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.
Tags
Grid
Asked by
Nick
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Tom
Top achievements
Rank 1
Larry
Top achievements
Rank 1
Konstantin Dikov
Telerik team
koms
Top achievements
Rank 1
Share this question
or