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

[Solved] Data Context for bound columns

0 Answers 25 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Chachi
Top achievements
Rank 1
Chachi asked on 04 Aug 2010, 04:39 PM
Is it possible to pass the entire object being bound to a bound column instead of just a property?  One of my columns is going to be a dropdown list based on the Status property of the model that the row is being bound to.  What I want to do is pass the model into an Html helper, so I can make sure that the dropdown list has the correct options in it.

Here's my grid code:
Html.Telerik().Grid<TopicModel>()
    .Name("TopicsGrid")
    .Columns(columns =>
    {
        columns.Bound( o => o.Title );
        columns.Bound( o => o.SectionName );
        columns.Bound( o => o.LastUpdated );
        columns.Bound( o => o.Status );
        columns.Bound( o => o.ID )
            .Title( "Action" )
            .ClientTemplate( Html.ActionSelect( DATACONTEXT ) );
    })
    .DataBinding( dataBinding =>
    {
        dataBinding.Ajax()
            .Select( "_AuthorGridSelect", "Dashboard" );
    })
    .Pageable()
    .Sortable()
    .Scrollable()
    .Filterable()

So I guess my question is two-fold: 1.) Is what I want to do even possible? and 2.) How do I do it?

Thanks!

UPDATE:
I was able to work around this by making a property on my model object that creates the dropdown list, so the code for that column looks like:
columns.Bound( o => o.ActionSelect )
    .Title( "Action" )
    .ClientTemplate( "<#= ActionSelect #>" );

I am still interested to know if what I asked in the initial post is possible though.
Tags
Grid
Asked by
Chachi
Top achievements
Rank 1
Share this question
or