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

[Solved] Command & LoadSettings

1 Answer 104 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.
Jim
Top achievements
Rank 1
Jim asked on 13 Oct 2011, 08:40 PM
 My objective is to use the .LoadSettings method to create columns as well as have a Select command. I am new enough to Telerik's MVC controls to expect that I have just missed something. I have also looked through a bunch of forum posts and just can't find a good answer.

So here is my proposed Razor Grid definition in the view:

@{Html.Telerik().Grid(Model)
.Name("AccountReviewGrid")
.DataKeys( keys => keys.Add( model => model.WorkflowID ) )
.DataBinding( db => db.Ajax()
.Select("Details","AccountReviewController") )
.Columns(columns => columns
.LoadSettings((IEnumerable<GridColumnSettings>)ViewData["Columns"]))
.Columns(columns => columns.Command(commands => { commands.Select(); }))
.Pageable()
.Sortable()
.Scrollable( s => s.Height(400) )
.Resizable( r => r.Columns(true) )
.Reorderable( reorder => reorder.Columns(true) )
.Filterable( )
.ClientEvents( events => events
.OnColumnResize("onResize")
.OnColumnReorder("onReorder")
)
.Render();
}

The 2nd .Columns is ignored ( seems reasonable ).

I would hate to loose the functionality that I have by building my column settings in the controller ( i am specifying size and order ).  Any thoughts on how to accomplish this?

EDIT --
So I have discovered the ClientTemplate property on GridColumnSettings but apparently this won't work with server side binding. It also appears there is no Template property on GridColumnSettings.  I feel like I am close to a solution but still it evades me.

1 Answer, 1 is accepted

Sort by
0
Jim
Top achievements
Rank 1
answered on 13 Oct 2011, 10:07 PM
I was able to resolve this problem by
1) add ClientTemplate to my GridColumnSettings
    new GridColumnSettings 
{
Member= "WorkflowID",
Title = "Action",
ClientTemplate = "<a href=\"" + Url.Content("~/AccountReview/Details/") + "<#= WorkflowID #>\">edit</a>",
Filterable = false,
Groupable = false,
}

2) Only using Ajax calls to load my data

@{Html.Telerik().Grid<AccountReviewModel>()
.Name("AccountReviewGrid")
.Columns(columns => columns
.LoadSettings((IEnumerable<GridColumnSettings>)ViewData["Columns"]))
.DataBinding( db => db.Ajax().Select( "_Index", "AccountReview" ))
.Pageable()
.Sortable()
.Scrollable( s => s.Height(400) )
.Resizable( r => r.Columns(true) )
.Reorderable( reorder => reorder.Columns(true) )
.Filterable( )
.ClientEvents( events => events
.OnColumnResize("onResize")
.OnColumnReorder("onReorder")
)
.Render();
}
Tags
Grid
Asked by
Jim
Top achievements
Rank 1
Answers by
Jim
Top achievements
Rank 1
Share this question
or