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

An item with the same key has already been added.

1 Answer 587 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Gavin
Top achievements
Rank 1
Gavin asked on 22 Jun 2016, 07:23 AM

Hi, I have seen this error in a number of threads on the forum, none of which seem to be caused by the same thing as I am trying. 

 

All it amounts to is using the same 'Id' column in the expressions for both a custom command routing value and the datasource server() model id mapping. I dont really understand why using the id in these two places should cause this problem?

 

            @(Html.Kendo().Grid(Model.DetailRecords).Name("MyGrid")
                .Columns(columns =>
                {
                    columns.Command(commands => commands.Custom("View").Action("Index", "Detail")
                        .DataRouteValues(rv => rv.Add(m => m.Id)));
                    columns.Bound(m => m.Heading);
                })
                .DataSource(ds => ds.Server().Model(model => model.Id(m => m.Id)))
            )

If this is a bug, is there a work around I can use?

 

Thanks,

Gavin

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 24 Jun 2016, 06:09 AM
Hello Gavin,

The Id field from the model will be automatically passed as parameter for the custom command, so that is why you are receiving the error message. You can safely remove that field from the DataRouteValues and you will still be to retrieve it.

Hope this helps.


Regards,
Konstantin Dikov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Gavin
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or