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

[Solved] In the Grid control with in-cell editing, how to move a javascript variable to the grid DefaultDataItem?

1 Answer 30 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jeff
Top achievements
Rank 1
Jeff asked on 14 May 2012, 02:57 AM
      Html.Telerik().Grid<ADTO>()
                        .Name("Grid")
                        .Editable(editing => editing.Mode(GridEditMode.InCell)
                            .DefaultDataItem(new ADTO
                            {
                                Name = selectedFeatureName <= "this need to be from the javascript variable selectedFeatureName 
below",
                            })

......

<script type="text/javascript">
    var selectedFeatureName; <== this is the variable the need to be moved to the Name field above.

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 16 May 2012, 01:51 PM
Hello Jeff,

If the property isn't bound to the first column which is put in edit mode when adding a row, you can set the default value in the editing defaultDataItem client-side property e.g.
var grid = $("#Grid").data("tGrid");
grid.editing.defaultDataItem.Name = selectedFeatureName;
If it is bound to the first column, you should use the OnEdit client-side event to set the value to the input because the editor is created when initializing the Grid.

Kind regards,
Daniel
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
Tags
Grid
Asked by
Jeff
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or