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

[Solved] ToolBar in DetailView appears in MasterView

2 Answers 63 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.
Mario
Top achievements
Rank 1
Mario asked on 25 Jan 2012, 03:49 PM
Hi guys

I've encoutered a strage problem.
I've tried to add a ToolBar with a Template in a DetailView, but it appears on the Master View.
Here my code
Html.Telerik().Grid<myNamespace.myMasterModel>()
    .Name("myMaster")
    .DataKeys(keys =>
    {
        keys.Add(p => p.id);
    })
    .DataBinding(dataBinding =>
    {
        dataBinding.Ajax()
            .Select("_SelectMasterMethod", "myContr")
            .Update("_UpdateMasterMethod", "myContr");
    })
    .Columns(columns =>
    {
        columns.Bound(x => x.id);
        columns.Bound(x => x.Description);                       
        columns.Command(commands => { commands.Edit().ButtonType(GridButtonType.ImageAndText); }).Title("Commands");
    })
 
    .DetailView(details => details.ClientTemplate(Html.Telerik().Grid<myNamespace.myDetailModel>()
        .Name("myDetail_<#= id #>")
        .ToolBar(toolBar => toolBar.Position(GridToolBarPosition.Top).Template(() =>
        {
            %>Hi this is a detail toolbar<%
        }))
        .DataKeys(k =>
            {
                k.Add(p => p.id);                   
            })
        .DataBinding(dataBinding => dataBinding.Ajax()
                .Select("_SelectDetailsMethod", "myContr", new { id = "<#= id #>" })
                .Update("_UpdateDetailsMethod", "myContr"))
        .Columns(cols =>
        {
            cols.Bound(x => x.id);
            cols.Bound(x => x.Description);               
            cols.Command(commands => { commands.Edit().ButtonType(GridButtonType.ImageAndText); }).Title("Commands");
        })
        .ToHtmlString()
 
    ))
    .Editable(editing => editing.Mode(GridEditMode.PopUp))
    .Pageable(x => x.PageSize(50))
    .Sortable()
    .Render();

Anyone can help me?

Thank you


2 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 26 Jan 2012, 11:54 AM
Hi Mario,

In your approach you write your template content directly to the output stream. This is why the template is rendered before the Grid hierarchy. 
So you have two options to assign template using the other overloads of the Template method:
  1. .ToolBar(toolBar => toolBar.Position(GridToolBarPosition.Top).Template("This is the detail toolbar"))
  2. .ToolBar(toolBar => toolBar.Position(GridToolBarPosition.Top).Template(o =>
            {
                return "This way you can execute more complex logic" + DateTime.Now;
            }))

I hope this helps.

Greetings,
Petur Subev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now
0
Mario
Top achievements
Rank 1
answered on 26 Jan 2012, 12:26 PM
Hi Petur

it works properly now, thank you!
Tags
Grid
Asked by
Mario
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Mario
Top achievements
Rank 1
Share this question
or