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

Kendo UI Grid - Model.ID

3 Answers 202 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vivek
Top achievements
Rank 1
Vivek asked on 11 Sep 2012, 01:08 AM

I have written the following code using ASP.NET MVC3 and it's throwing me an error at the bold line(.Model(Function(model) model.id(Function(p) p.CostCentreID). It's saying that the expression does not produce a value? I thought it's asking for a primary key column only? Isn't that the case?

Please help

@ModelType IEnumerable(Of Mail.BAL.CostCentre)

@Code
    ViewData
("Title") = "Index"
End Code

@(Html.Kendo().Grid(Model) _
   
.Name("CostCentres") _
   
.Columns(Function(modelItem) modelItem.Bound(Function(p) p.CostCentreID).Hidden) _
   
.Columns(Function(modelItem) modelItem.Bound(Function(p) p.CostCentre)) _
   
.Columns(Function(modelItem) modelItem.Bound(Function(p) p.Active)) _
   
.ToolBar(Function(toolbar) toolbar.Create()) _
   
.Groupable() _
   
.Pageable() _
   
.Sortable() _
   
.Scrollable() _
   
.DataSource(Function(datasource) datasource _
                   
.Ajax() _
                   
**.Model(Function(model) model.Id(Function(p) p.CostCentreID)) _**
                   
.Create(Function(create) create.Action("Create", "Home")))
   
)

3 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 13 Sep 2012, 10:40 AM
Hi Vivek,

I suspect that the error caused by the fact that the Sub should be used instead of a Function:

.Model(Sub(model) model.Id(Function(p) p.CostCentreID)) _

Regards,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Vivek
Top achievements
Rank 1
answered on 14 Sep 2012, 02:21 AM
Hi Rosen,

That's syntax for lambda expression Function(x) x.something. It has nothing to do with actual Function/Sub in VB.NET.

0
Vivek
Top achievements
Rank 1
answered on 14 Sep 2012, 04:15 AM
sorry rosen. my fault. you are right. it works now. i thought it's just a lambda expression and has nothing to do with sub/function.
Tags
Grid
Asked by
Vivek
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Vivek
Top achievements
Rank 1
Share this question
or