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

How to access multiple model items in Columns.bound entry

2 Answers 275 Views
Grid
This is a migrated thread and some comments may be shown as answers.
BRiddle
Top achievements
Rank 1
BRiddle asked on 30 Jan 2015, 06:59 PM
I have little experience with the Kendo Grid HTMLHelper for ASP.Net MVC and have a couple of different scenarios in which I ideally need to specify multiple model items to be used in a "Columns.Bound()" clause for an @Html.kendo.grid declaration.   One is where I need to concatenate two model items for the value of a particular column.  

The other is where I need to have the title/tooltip for a column for one model item be the contents of another model item in that same row as in the following:

columns.Bound(model => model.modelItem1).Title("Reason Dump Taken").ClientTemplate("#= getTruncatedValue(modelItem1,36)#").Width(180).HtmlAttributes(new { title = " #= modelItem2 # "});

In both cases adding the 2nd model item, either as "modelItem2" or as "model.modelItem2" throw syntax errors.  I've searched this forum and others and haven't seen a syntax for simply implementing the first one.  

I did see a more lengthy workaround for the second that involved registering a javascript function to be called when a tooltip was requested; getting the grid row in that function, and trying to provide the 2nd model item via that mechanism. 

But it would be much easier if I could just specify something more like title = " #= modelItem2 # ".

Thanks in advance,
-Bob

2 Answers, 1 is accepted

Sort by
0
BRiddle
Top achievements
Rank 1
answered on 02 Feb 2015, 06:30 PM
Please ignore this post as it was in my error.    The problem with using the " #= modelItem2 # " was that the modelItem2 column was being populated in an "Index" method but not in a Get...GridData() method that pre-dated the column's addition; causing the column to always be null.   My bad.
0
Dimiter Madjarov
Telerik team
answered on 03 Feb 2015, 07:58 AM
Hi Bob,


Thanks for the update. I am glad the issue is resolved.

Regards,
Dimiter Madjarov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
BRiddle
Top achievements
Rank 1
Answers by
BRiddle
Top achievements
Rank 1
Dimiter Madjarov
Telerik team
Share this question
or