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

grid add command won't work

4 Answers 345 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Willem
Top achievements
Rank 1
Willem asked on 21 Sep 2012, 12:57 PM
I'm having some issues getting the kendo grid for mvc to work properly (especially the add button in the toolbar). I have a grid with editing in a popup window. For this I'm using a custom template which is in Views/Location/EditorShow.

The edit command is working just fine since this is showing up a popup for the user to edit data in (basically this loads Views/Location/EditorShow like I want it to). The delete command is also working just fine too.

The problem however is the Add command which is situated inside the toolbar. This one does not seem to have a correct url (it's pointing to the root of the website). Also find attached a screenshot showing to source of the add button. If I surf to ?GridLocations-mode=insert manually however a create popup is showing up.

Quite a strange situation, because there seems to be only a problem with the url of the add button in the toolbar.
Any ideas on what may be causing this??

P.S. Below is the code I'm using in my .cshtml file:

@Html.Kendo().Grid(Model).Name("GridLocations").Columns(columns =>
    {
        columns.Bound(l => l.Name).Title("Name");
        columns.Command(command =>
       {      
          command.Edit().Text("Edit");
          command.Destroy().Text("Delete");               
       }).HeaderTemplate("Manage");
         
}).ToolBar(toolbar => toolbar.Create().Text("Create")).DataSource(dataSource => dataSource
        .Server() 
        .Model(model => model.Id(l => l.Id))         
        // Configure CRUD -->       
        .Create(create => create.Action("Create", "Locations"))
            .Read(read => read.Action("Index", "Locations"))
            .Update(update => update.Action("Update", "Locations"))
            .Destroy(destroy => destroy.Action("Delete", "Locations"))       
        // <-- Configure CRUD   
        ).Editable(editable => editable.Mode(GridEditMode.PopUp).TemplateName("EditLocations"))

I don't think this does contain any strange stuff, since it's mostly the same as the examples on the website.
Any thoughts on why the add button is not working properly like expected?

4 Answers, 1 is accepted

Sort by
0
Willem
Top achievements
Rank 1
answered on 25 Sep 2012, 06:57 PM
Any thoughts on this one?
0
Sergey
Top achievements
Rank 1
answered on 26 Sep 2012, 10:10 AM
Maybe you forgot closing bracket for .ToolBar?
}).ToolBar(toolbar => toolbar.Create().Text("Create"))
.DataSource
0
Willem
Top achievements
Rank 1
answered on 26 Sep 2012, 10:10 PM
That's definitely not the case since the rest of the grid is working fine and C# code would show up as plain text below the grid if any brackets were missing. I know this since I've experienced behaviour like that lately :)

FYI, there's some logic to retrieve static text in there normally but for this example I removed that and put in hardcoded strings instead. Indeed there is a bracket missing in the example, but I can assure you it's not in the actual code.
0
Willem
Top achievements
Rank 1
answered on 28 Sep 2012, 02:21 PM
Problem solved, turns out if you don't have the serverside commands (edit, create etc) defined in your controller then the buttons will not generate correct links. After adding a Create action to my controller, everything is working just fine...
Tags
Grid
Asked by
Willem
Top achievements
Rank 1
Answers by
Willem
Top achievements
Rank 1
Sergey
Top achievements
Rank 1
Share this question
or