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

Failing on Create new post when grid contains relational data

3 Answers 130 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kenneth
Top achievements
Rank 2
Kenneth asked on 12 Aug 2012, 06:51 AM

I am working with the good example of Editing custom editor under the MVC examples.
It shows how to build a dropdownlist for use when editing a cell in a grid.
I have to create a new post in the grid and I add the following to the file; Editing_Custom.cshtml:

.Create(create => create.Action("EditingCustom_Create", "Grid"))
.ToolBar(toolBar => { toolBar.Save(); toolBar.Create(); })

And I already get an error here before I come to do the coding in the .cs-file.
When debugging with firebug, I get an error from javascript that says: ReferenceError: Employee is not defined.
Employee is the class that is used for making the dropdownlist.
Could someone please give me a hint on what I have to do when creating a post in a grid with relational data?
Thanks :o)

3 Answers, 1 is accepted

Sort by
0
Kenneth
Top achievements
Rank 2
answered on 15 Aug 2012, 07:17 PM
Perhaps this is a bug thats inherited from the old MVC grid: http://www.telerik.com/community/forums/aspnet-mvc/grid/script-registrar-not-loading-scripts-for-controls-used-in-client-templates.aspx

It's a big problem for me that the dropdownlist fails when I am hitting the Add new item button.
Are there someone who perhaps could help? I am so stucked.
0
Accepted
Nikolay Rusev
Telerik team
answered on 16 Aug 2012, 07:17 AM
Hello Kenneth,

There are few demos showing CRUD operations with dropdown editors. Can you reproduce the behavior on one of those demos:
http://demos.kendoui.com/web/grid/foreignkeycolumn.html
http://demos.kendoui.com/web/grid/editing-custom.html

Greetings,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Kenneth
Top achievements
Rank 2
answered on 16 Aug 2012, 10:17 AM
YES YES YES – Thank you – it works. I hadn’t seen the Foreign key example.
To get my code up working, I should implement this column as in the foreignkey example:
columns.ForeignKey(p => p.EmployeeID, (System.Collections.IEnumerable)ViewData["employees"], "EmployeeID", "EmployeeName");

I should mention that the cshtml-code in the two links you send, aren’t adjusted to the grid that it produces.
The editing-custom.cshtml refers to properties like OrderID, Employee and ShipAddress,
while the editing-custom.html uses ProductName, Category and UnitPrice.
The same goes for the foreign key example.

But my code is working now - thanks ;o)
Tags
Grid
Asked by
Kenneth
Top achievements
Rank 2
Answers by
Kenneth
Top achievements
Rank 2
Nikolay Rusev
Telerik team
Share this question
or