I am using the Restful Routing (http://restfulrouting.com/) library in my MVC5 project. Restful Routing gives me true REST based actions for my controllers. I'm trying to use the Kendo Grid in edit mode against these actions. Using the MVC wrapper, I have the following code for my data source:
The actions there should resolve to the URL /mappings/{id} with the exception of Read and Create. When I look at the generated JavaScript code though, I get the following:
There are no definitions for the update or destroy actions. If I change .Action to .Url, then I'm able to apply an HttpVerb. I figure the Url is the way to go, but how do I get the models Id within the Url string? I thought that perhaps the CleintTemplate placeholders would work, but they don't, e.g.:
So, how can I get the Model's Id in a Url?
Thanks,
Damien
.DataSource(ds => ds
.Ajax()
.Model(model => model.Id(mapping => mapping.Id))
.Read(read => read.Action("list", "mappings").Type(HttpVerbs.Get))
.Create(create => create.Action("create", "mappings").Type(HttpVerbs.Post))
.Update(update => update.Action("update", "mappings").Type(HttpVerbs.Put))
.Destroy(destroy => destroy.Action("destroy", "mappings").Type(HttpVerbs.Delete))
.PageSize(20)
)
"dataSource"
: {
"transport"
: {
"prefix"
:
""
,
"read"
: {
"url"
:
"/mappings/list"
,
"type"
:
"GET"
},
"create"
: {
"url"
:
"/mappings"
,
"type"
:
"POST"
}
},
.Update(update => update.Url(Url.Action("Update", "Mappings", new { id = "#=Id#"})).Type(HttpVerbs.Put))
Thanks,
Damien