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

[Solved] Cannot get datakey of mvc grid in controller

0 Answers 29 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
reynald lawrence
Top achievements
Rank 1
reynald lawrence asked on 13 Nov 2012, 09:21 AM
Hi, I would like to ask how to get the value of the datakey in the mvc grid, when the grid is in update event in the controller.
Here's my script for the grid:

@(Html.Telerik().Grid<BG.MVC.Models.SaladEntryListViewModel>()
        .Name("SaladEntryGrid")
        .DataKeys(keys =>
        {
            keys.Add(p => p.Country_No);


        })
        .DataBinding(dataBinding =>
        {
            dataBinding.Ajax()
                .Select("GetSaladEntry", "SaladEntry")
                .Update("EditingInline_Update", "SaladEntry")
                .Delete("EditingInline_Destroy", "SaladEntry");
        })
        .Columns(columns =>
        {
            columns.Bound(c => c.Country_No).Title("Country No").Visible(false).Width(100);
            columns.Bound(c => c.Effective_date).Title("Effective Date").Format("{0:d}").Width(160).ReadOnly(true);
            columns.Bound(c => c.Scale_Min).Title("BG1 Min").Width(100);
            columns.Bound(c => c.Scale_Max).Title("BG7 Max").Width(160);
            columns.Bound(c => c.Currency).Title("Currency").Width(100);


            columns.Command(commands =>
            {
                commands.Edit();
                commands.Delete();


            }).Width(180).Title("Commands");
        })


        .Editable(editing => editing.Mode(GridEditMode.InLine))
            .Pageable()
            .Scrollable()
            .Selectable()
           .Pageable(paging => paging.Style((GridPagerStyles.PageInput | GridPagerStyles.Numeric | GridPagerStyles.PageSizeDropDown | GridPagerStyles.NextPrevious)).Position(GridPagerPosition.Bottom).PageTo(1))
            .Sortable()
            .ClientEvents(events => events.OnDataBinding("onDataBinding"))
)

In the controller I always get the value of 0 for the datakey value field.

Hope i can find help in here.

Many Thanks
Tags
General Discussions
Asked by
reynald lawrence
Top achievements
Rank 1
Share this question
or