.kendoTooltip仅在行上的详细网格上

时间:2018-02-08 07:31:45

标签: c# kendo-grid kendo-asp.net-mvc

我有一个剑道网格和一个细节网格,如下所示:

@(Html.Kendo().Grid<SDB.Models.NettoVergelijking.Dienstverband>()
        .Name("overzicht-grid")
        .AutoBind(false)
        .Columns(columns =>
        {
            columns.Bound(d => d.Naam).Title("Medewerker").ClientTemplate("<span title='${Naam}'>${Naam}</span>").Width(300)
                .Filterable(f =>
                {
                    f.Extra(false);
                    f.Operators(op =>
                    {
                        op.ForString(str =>
                        {
                            str.Clear().Contains("Bevat");
                        });
                    });
                });
            columns.Bound(d => d.Contractvorm).Title("Contractvorm").ClientTemplate("<span title='${Contractvorm}'>${Contractvorm}</span>").Width(200).Filterable(ftb => ftb.Multi(true)); ;


            columns.Bound(d => d.Run1.Netto).Title("Periode 1").HeaderTemplate("<div class ='periode1jaar'></div >").Filterable(true).HtmlAttributes(new { style = "text-align:right;" }).Width(220).ClientTemplate("# if (Run1.Netto != 0) { #  #= kendo.toString(Run1.Netto, 'n2') #  # } #").HeaderHtmlAttributes(new { style = "text-align:right;" });





            columns.Bound(d => d.Run2.Netto).Title("Periode 2").HeaderTemplate("<div class ='periode2jaar'></div >").Filterable(true).HtmlAttributes(new { style = "text-align:right;" }).Width(220).ClientTemplate("# if (Run2.Netto != 0) { #  #= kendo.toString(Run2.Netto, 'n2') #  # } #").HeaderHtmlAttributes(new { style = "text-align:right;" });


            columns.Bound(d => d.VerschilPercentage).Filterable(false).HtmlAttributes(new { style = "text-align:right;", @class = "NettoVergelijkingVerschil" }).ClientTemplate("# if (VerschilPercentage != 0) { # %   #= kendo.toString(VerschilPercentage, 'n2') #  # } else { # % 0  # } #").Width(165).Format("{0:P}").HeaderHtmlAttributes(new { style = "text-align:right;" }).Hidden();


            columns.Bound(d => d.Verschil).Filterable(false).HtmlAttributes(new { style = "text-align:right;", @class = "NettoVergelijkingVerschil" }).ClientTemplate("# if (Verschil != 0) { #  € #= kendo.toString(Verschil, 'n2') #    # } else { # €  0,00  # } #").Width(165).Format("{0: #.00}").HeaderHtmlAttributes(new { style = "text-align:right;" });
        })
    .Filterable(f => f.Mode(GridFilterMode.Menu))
    .Sortable()
    .Events(e => e.DataBound("OngridDatabound"))
    .Pageable(pager => pager.PageSizes(new List<object>
        { 25, 50, 100, 200, 500 }))
        .ClientDetailTemplateId("overzicht-grid-details")
        .Excel(e => e.AllPages(true))
        .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(50)
        .ServerOperation(false)
        .Model(model =>
        {
            model.Id(d => d.Id);
            model.Field(f => f.Naam);
            model.Field(f => f.Contractvorm);
            model.Field(f => f.Run1.Netto);
            model.Field(f => f.Run2.Netto);
        })
        .Read(r => r.Action("GetOverzicht", "NettoVergelijking").Data("getData"))
        .Sort(d => d.Add(a => a.Verschil).Descending()
        )
        )
)

<script id="overzicht-grid-details" type="text/kendo-tmpl">
    @(Html.Kendo().Grid<SDB.Models.NettoVergelijking.Detail>()
                .Name("overzicht-grid1-details-#=Id#")
                .Columns(columns =>
                {
                    columns.Bound(o => o.Omschrijving).Width(270)
                        .Filterable(false).HeaderTemplate(" ");
                    columns.Bound(o => o.Belastbaarheid).Width(200).HtmlAttributes(new { style = "cursor:pointer;" });
                    columns.Bound(o => o.Waarde1).Width(220)
                        .ClientTemplate("\\# if (Waarde1 != 0 && Waarde1 != null) { \\#  \\#= kendo.toString(Waarde1, 'n2') \\#  \\# } else { \\#  \\# } \\#")
                        .ClientFooterTemplate("\\#=kendo.toString(sum, 'n2')\\#")
                        .FooterHtmlAttributes(new { style = "text-align:right;" }).Filterable(false).HeaderTemplate(" ").HtmlAttributes(new { style = "text-align:right;" }).HeaderHtmlAttributes(new { style = "text-align:right;" });


                    columns.Bound(o => o.Waarde2).Width(220)
                        .ClientTemplate("\\# if (Waarde2 != 0 && Waarde2 != null) { \\#  \\#= kendo.toString(Waarde2, 'n2') \\#  \\# } else { \\#  \\# } \\#")
                        .ClientFooterTemplate("\\#=kendo.toString(sum, 'n2')\\#")
                        .FooterHtmlAttributes(new { style = "text-align:right;" }).Filterable(false).HeaderTemplate(" ").HtmlAttributes(new { style = "text-align:right;" }).HeaderHtmlAttributes(new { style = "text-align:right;" });


                    columns.Bound(o => o.Verschil)
                        .ClientTemplate("\\# if (Verschil != 0 && Verschil != null) { \\# € \\#= kendo.toString(Verschil, 'n2') \\#  \\# } else {  \\# €   0  \\# } \\#")
                        .ClientFooterTemplate("\\#=kendo.toString(sum, 'n2')\\#")
                        .FooterHtmlAttributes(new { style = "text-align:right;" }).Filterable(false).HeaderTemplate(" ").HtmlAttributes(new { style = "text-align:right;" }).HeaderHtmlAttributes(new { style = "text-align:right;" });                  


                })
                .Filterable(f => f.Mode(GridFilterMode.Menu))
                .DataSource(dataSource => dataSource
                    .Ajax()
                    .Aggregates(a =>
                    {
                        a.Add(x => x.Waarde1).Sum();
                        a.Add(x => x.Waarde2).Sum();
                        a.Add(x => x.Verschil).Sum();
                        a.Add(x => x.VerschilPercentage).Sum();
                    })
                    .Model(model =>
                    {
                        model.Id(d => d.Id);
                        model.Field(f => f.Type);
                        model.Field(f => f.Omschrijving);
                        model.Field(f => f.Waarde1);
                        model.Field(f => f.Waarde2);
                        model.Field(f => f.Verschil);                       
                    })
                    .Group(groups => groups.Add(p => p.Type))
                    .Sort(s => s.Add(a => a.LoonfactorCode).Ascending())
                    .Read(read => read.Action("GetPeriodeDetails", "NettoVergelijking", new { dienstverbandId = "#=Id#" }).Data("getData"))
                )
                .ToClientTemplate()
    )

我有一个剑道工具提示,就像这样;

$("#overzicht-grid").kendoTooltip({
        filter: "td:nth-child(3)",
        content: function (e) {
            return "belastbaarheidcode " + e.target.html();
        }
    });

但我想只在网格细节上提供工具提示:

overzicht-grid1-details-#=Id#

但是你看到它也有一个Id。因为工具提示也适用于overzicht网格。而且不仅仅是在细节网格上。

那么改变什么只适用于细节网格?

谢谢

2 个答案:

答案 0 :(得分:0)

使用工具提示选择器#overzicht-grid .k-detail-cell

$("#overzicht-grid .k-detail-cell").kendoTooltip({
    filter: "td:nth-child(3)",
    content: function (e) {
        return "belastbaarheidcode " + e.target.html();
    }
});

答案 1 :(得分:0)

就像这样:

   $("#overzicht-grid").kendoTooltip({
        filter: ".k-detail-cell td:nth-child(3)",
        content: function (e) {
            return "belastbaarheidcode " + e.target.html();
        }
    });