I have a Grid with Server() datasource in an MVC5/EF6 Razor app with your 14.1.528.0 build. I need to return a couple of model values plus a non-model Guid value from the ViewBag when a user selects a row. I originally tried using the "onRowSelect" approach, but discovered that the dataItem() array was always null in the onRowSelect method when using a Server() datasource. So I can get the first model field, the "Id" column, via the DataSource model reference. But there was no way to obtain the selected row's 2nd model field in the "onRowSelect" method. (BTW: Please add my vote for a feature other developers have requested: providing some way to access column values in the onRowSelect() when using a Server datasource).
I next tried using a custom Command button in each row. It was easy to return a Url Action doing "DataRouteValues( route =>Route.Add()" to add the two model values for the selected row.
But with this approach, I cannot find a syntax to return the non-model Guid value via Route.Add(). I've tried "Route.Add("@ViewBag.MyGuid",". I've tried setting a JavaScript var equal to the ViewBag value in a page script block and doing "Route.Add(myJsGuidVar,", etc. But the resulting error message makes it clear that Route.Add() will only accept a model reference.
I'm new to MVC and am assuming I'm making a simply mistake. I'd rather not have to make a new ViewModel to add this column and take the time to redundantly populate this same Guid into every row. What am I missing here? Is there a way to add either a ViewBag property or a non-modal JavaScript Var to the DataRouteValues of the generated call?
Thanks!
-Bob
I next tried using a custom Command button in each row. It was easy to return a Url Action doing "DataRouteValues( route =>Route.Add()" to add the two model values for the selected row.
But with this approach, I cannot find a syntax to return the non-model Guid value via Route.Add(). I've tried "Route.Add("@ViewBag.MyGuid",". I've tried setting a JavaScript var equal to the ViewBag value in a page script block and doing "Route.Add(myJsGuidVar,", etc. But the resulting error message makes it clear that Route.Add() will only accept a model reference.
I'm new to MVC and am assuming I'm making a simply mistake. I'd rather not have to make a new ViewModel to add this column and take the time to redundantly populate this same Guid into every row. What am I missing here? Is there a way to add either a ViewBag property or a non-modal JavaScript Var to the DataRouteValues of the generated call?
Thanks!
-Bob