【问题标题】:how to Change Caption of popup kendo grid by html helper in add window如何在添加窗口中通过 html 助手更改弹出剑道网格的标题
【发布时间】:2014-02-12 14:34:54
【问题描述】:

我正在使用弹出剑道网格,我使用添加新记录和编辑模式,我想在添加新记录时通过 html 助手更改弹出窗口剑道网格的标题。

    <div class="k-rtl">

    @(Html.Kendo().Grid<KendoSample.Models.Person>()
   .Name("grid")
   .Columns(columns =>
    {
        columns.Bound(p => p.PersonId).Title("Person Code").Width(100).Sortable(true);
        columns.Bound(p => p.Name).Title("Name").Width(200).Sortable(true);
        columns.Bound(p => p.Family).Title("Family").Sortable(false);
        columns.Command(c => { c.Edit().Text("Edit").CancelText("Cancel").UpdateText("save"); c.Destroy().Text("Delete"); });            
    })
.Pageable()

.ToolBar(s => { s.Create().Text("ایجاد"); })
.Editable(c => { c.TemplateName("Default").Mode(GridEditMode.PopUp); c.Window(x => x.Title("ویرایش")); })


.Scrollable()
.Sortable()
.HtmlAttributes(new { style = "height:430px;" })
.DataSource(dataSource => dataSource
    .Ajax()
                            .Model(c => c.Id(p => p.PersonId))
                            .Create(c => c.Action("Read", "Home"))

    .Read(read => read.Action("EditingPopup_Read", "Grid"))
    .Update(update => update.Action("EditingPopup_Update", "Grid"))
    .Destroy(update => update.Action("EditingPopup_Destroy", "Grid"))                                


                            .ServerOperation(true)
    .PageSize(8)
    .Read(read => read.Action("EditingPopup_read", "Home"))
 )
 .Sortable()
 .Filterable()
 )

</div>

请告诉我如何在添加模式下更改弹出窗口的标题。

【问题讨论】:

    标签: c# asp.net-mvc kendo-ui popup kendo-asp.net-mvc


    【解决方案1】:

    我通过使用编辑事件解决了这个问题。

    .Events(events => events.Edit("insertPopupCaption")
    
    <script>
     function insertPopupCaption(e) {
     if (e.model.isNew()) {
         $('.k-window-title').text("add");        
     }   
    }
    </script>
    

    【讨论】:

      【解决方案2】:

      @Iraj,在 $('.k-window-title') 上匹配的问题在于它会更改该页面上每个 Kendo UI 窗口的标题。我有一个嵌套网格条目页面,其中第二个网格位于弹出窗口中。作为一种解决方法,我将我的编辑模板放在一个带有“bdPopup”类的 div 中。然后为了获得该表单的标题,我使用了以下语法:

      $(".bdPopup").parent().parent().parent().children(".k-window-titlebar").children(".k-window-title").text("Add")
      

      【讨论】:

        【解决方案3】:

        您可以在网格编辑事件中更改标题。

            grid.bind("edit", function (event) {
            event.container.parent().find('.k-window-title').text(event.model.isNew() ? "New" : "Edit");
        });
        

        【讨论】:

          【解决方案4】:

          不能直接回答您的问题。但是我正在为我的 kendowindow 的标题执行以下操作

                  drilldownpopup.data('kendoWindow').title("My Title");
                  $('.k-window-actions').html('<span class="titletext">' + "Make & Hold Details" + '</span><a href="#" class="k-window-action k-link"><span class="k-icon k-i-close"></span></a>');
          

          【讨论】:

            【解决方案5】:

            这是另一种方式。

            @(Html.Kendo().Grid<Model>()
            ....
            ....
            ....
            .Events(events =>
                {
                    events.Edit("onEditKendoGrid");
                })
            )
            
            <script>
            function onEditKendoGrid(e) {
                //set edit window title
                e.container.kendoWindow("title", "Title goes here...");
            }
            </script>
            

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2017-12-28
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              相关资源
              最近更新 更多