How to access multiple model items in Columns.bound entry

3 posts, 0 answers
  1. BRiddle
    BRiddle avatar
    24 posts
    Member since:
    Sep 2010

    Posted 30 Jan 2015 Link to this post

    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,
  2. BRiddle
    BRiddle avatar
    24 posts
    Member since:
    Sep 2010

    Posted 02 Feb 2015 Link to this post

    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.
  3. Dimiter Madjarov
    Dimiter Madjarov avatar
    2312 posts

    Posted 03 Feb 2015 Link to this post

    Hi Bob,

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

    Dimiter Madjarov

    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.

Back to Top