0
votes

I am new in MVC controls. I am using .ToolBar(commands => commands.Insert()) in the telerik grid that is bind to journey model class like this (@(Html.Telerik().Grid()). Now my question is that i want to call my partial view control when Insert/Edit button click.

Thank you

1

1 Answers

0
votes

It is not good practice to use ".ToolBar(commands => commands.Insert())" .This will work just for very simple models. You should use custom commands :

 .ToolBar(toolBar => toolBar.Template( @<text>
                     @Html.ActionLink("Add new ", "Action", "Controller",null, new {  @class = "t-button", })</text>))

, for insert , and custom command for edit :

columns.Command(commands =>
                    {
                        commands.Custom("Update").Text("Update")
                                .SendState(true).SendDataKeys(true)
                                .HtmlAttributes(new { f = "btnEdit" }).
                                 Action("Action", "Controller").Ajax(false);                      

                    }).Width("15%").Title("Title");

If you still want to use .ToolBar(commands => commands.Insert()),you should have in your grid something like this :

.DataBinding(dataBinding =>
        {
            dataBinding.Ajax()
                .Select("Action", "Controller")
                .Insert("Action", "Controller")
                .Update("Action", "Controller")
                .Delete("Action", "Controller");
        })

And now you should to have in Shared Folder in folder named EditorTempaltes and in this folder your partial views named like grid model ,but this is not good practice.