EditorTemplate don't work in Grid inside a template

3 posts, 0 answers
  1. Cuong
    Cuong avatar
    4 posts
    Member since:
    Feb 2019

    Posted 24 Feb Link to this post

    I have a View (name = 'step3Grid'). It's using popup with a Template ("_VendorQuotationTmp")

    01.@(
    02.        Html.Kendo().Grid<VendorQuotationDto>()
    03.        .Name("step3Grid")
    04.        .Columns(columns =>
    05.        {
    06.            columns.Bound(p => p.VendorName).Title(LanguageData["L-00323"])
    07.                .HtmlAttributes(new { style = "text-align:left;" })
    08.                .HeaderHtmlAttributes(new { style = "text-align:center; font-weight:bold", title = LanguageData["L-00323"] });
    09.            columns.Bound(p => p.PurchaseOrderName).Title(LanguageData["L-00284"])
    10.                .HtmlAttributes(new { style = "text-align: left" })
    11.                .ClientTemplate("#=PurchaseOrderName.toString().split('-').pop()#")
    12.                .HeaderHtmlAttributes(new { style = "text-align:center; font-weight:bold", title = LanguageData["L-00284"] });
    13.            columns.Bound(p => p.HasAttachedFile).Title(LanguageData["L-00060"])
    14.                .ClientTemplate("#if (HasAttachedFile && HasPDFAttachedFile) {#<img src='" + @Url.Content("/Content/images/common/pdf.png") + "' alt='PDF File' height='16' width='16' class='icon-file-attached' title='#=Attachment#'>#}# #if (HasAttachedFile && !HasPDFAttachedFile) {#<img src='" + @Url.Content("/Content/images/common/paperclip.png") + "' alt='Attached File' height='16' width='16' class='icon-file-attached' title='#=Attachment#'>#}#")
    15.                .HtmlAttributes(new { @onclick = "clickImagePDF('#=Attachment#'); return false;" })
    16.                .HeaderHtmlAttributes(new { style = "text-align:center; font-weight:bold", title = LanguageData["L-00060"] }).Width("65px");
    17. 
    18.            columns.Command(c =>
    19.            {
    20.                c.Edit().HtmlAttributes(new { title = LanguageData["B-00003"] });
    21.                c.Destroy().HtmlAttributes(new { title = LanguageData["B-00004"] });
    22.            })
    23.            .Title(LanguageData["L-00000"])
    24.            .Width("100px")
    25.            .HtmlAttributes(new { style = "text-align: center;" })
    26.            .HeaderHtmlAttributes(new { style = "text-align:center; font-weight:bold" });
    27.        })
    28.        .Events(e => e.Edit("onEditVendorQuo").Save("onSaveVendorQuo")/*.DetailExpand("onExpandVendorQuo")*/)
    29.        .Editable(e =>
    30.        {
    31.            e.Mode(GridEditMode.PopUp).TemplateName("_VendorQuotationTmp");
    32.            e.DisplayDeleteConfirmation(LanguageData["N-00019"]);
    33.        })
    34.        .ToolBar(toolbar =>
    35.        {
    36.            toolbar.Create().Text(LanguageData["B-00001"]);
    37.        })
    38.        //.ClientDetailTemplateId("template")
    39.        .Sortable()
    40.        .Selectable()
    67.        .Scrollable(a => a.Height("auto"))
    68.        .DataSource(dataSource => dataSource
    69.            .Ajax()
    70.            .PageSize(30)
    71.            .Model(model =>
    72.            {
    73.                model.Id(p => p.Id);
    74.            })
    75.        .Read(read => read.Action("ReadVendorQuotation", "PurchaseOrder", new { MrId = Model.MaterRequisId, @area = "Ship" }).Type(HttpVerbs.Post))
    76.        .Create(create => create.Action("CreateVendorQuotation", "PurchaseOrder", new { @area = "Ship" , shipId = ViewBag.ShipId }).Type(HttpVerbs.Post).Data("getParamVendorQuo"))
    77.        .Update(update => update.Action("UpdateVendorQuotation", "PurchaseOrder", new { @area = "Ship", shipId = ViewBag.ShipId }).Type(HttpVerbs.Post).Data("getParamVendorQuo"))
    78.        .Destroy(des => des.Action("DeleteVendorQuotation", "PurchaseOrder", new { @area = "Ship", shipId = ViewBag.ShipId }).Type(HttpVerbs.Post))
    79.        .Events(e => e.RequestStart("onRequestStartStep3").RequestEnd("onRequestEndStep3"))
    80.    ))

     

    Inside the popup ("_VendorQuotationTmp"),

    01.@(Html.Kendo().Grid<RequestQuoDetailDto>()
    02.        .Name("vendorquodetailGrid")
    03.        .Columns(columns =>
    04.        {
    05.            columns.Bound(p => p.PartCode).Title(LanguageData["L-00167"])
    06.                .HtmlAttributes(new { style = "text-align:left;" })
    07.                .HeaderHtmlAttributes(new { style = "text-align:center; font-weight:bold", title = LanguageData["L-00167"] }).Width("10%");
    08.            columns.Bound(p => p.PartName).Title(LanguageData["L-00168"])
    09.                .ClientTemplate("#=PartName# ").Width("38%")
    10.                .HtmlAttributes(new { style = "text-align: left" }).HeaderHtmlAttributes(new { style = "text-align:center; font-weight:bold", title = LanguageData["L-00168"] });
    11.            columns.Bound(p => p.Price).Title(LanguageData["L-00288"]).HtmlAttributes(new { style = "text-align: left" })

                             .EditorTemplateName("DecimalRound1") 

    12.                 .HeaderHtmlAttributes(new { style = "text-align:center; font-weight:bold", title = LanguageData["L-00288"] }).Width("12%");
    13. 
    14.            columns.Bound(p => p.FullGroupName).ClientGroupHeaderTemplate(" #= value #").Hidden();
    15.        })
    16.        .Events(e => e.Save("onSaveVendorQuoDetail"))
    17.        .Editable(e => e.Mode(GridEditMode.InCell))
    18.        .Groupable()
    19.        .Sortable()
    20.        .Selectable()
    21.        .Pageable(p => p.Messages(mes =>
    22.        {
    23.            mes.Display(LanguageData["N-00067"]);
    24.            mes.Empty(LanguageData["N-00068"]);
    25.            mes.Previous(LanguageData["B-00038"]);
    26.            mes.Next(LanguageData["B-00039"]);
    27.            mes.First(LanguageData["B-00040"]);
    28.            mes.Last(LanguageData["B-00041"]);
    29.        }))
    30.        .Filterable(filterable => filterable
    31.                    .Extra(false)
    32.                    .Messages(m => m.Info(LanguageData["B-00035"])
    33.                                    .Filter(LanguageData["B-00036"])
    34.                                    .Clear(LanguageData["B-00037"]))
    35.                    .Operators(operators => operators
    36.                        .ForNumber(str => str.Clear()
    37.                            .IsEqualTo(LanguageData["B-00033"])
    38.                            .IsNotEqualTo(LanguageData["B-00034"])
    39.                        )
    40.                        .ForString(str => str.Clear()
    41.                            .Contains(LanguageData["B-00031"])
    42.                            .StartsWith(LanguageData["B-00032"])
    43.                            .IsEqualTo(LanguageData["B-00033"])
    44.                            .IsNotEqualTo(LanguageData["B-00034"])
    45.                        ))
    46.        )
    47.        .Scrollable(a => a.Height("400px"))
    48.        .AutoBind(false)
    49.        .DataSource(dataSource => dataSource
    50.            .Ajax()
    51.            .Group(g => g.Add(f => f.FullGroupName))
    52.            .ServerOperation(false)
    53.            .PageSize(20)
    54.            .Model(model =>
    55.            {
    56.                model.Id(p => p.QuotationDetailId);
    57.                model.Field(f => f.PartCode).Editable(false);
    58.                model.Field(f => f.PartName).Editable(false);
    59.            })
    60.            .Read(read => read.Action("ReadDetailVendorQuo", "PurchaseOrder", new { @area = "Ship" }).Type(HttpVerbs.Post))
    61.    ))

     

    At column 'Price' of Grid. I applied EditorTemplate cho it and Price is double?. When I run program, I got error and popup can open. If I remove EditorTemplate of column 'Price' then program can run and this column is type ='text' not 'number'

    Can you tell me why is it ? You don't care about 'LanguageData'. I am not good English. If I have any misspelling, please forgive me. Thanks.

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

  2. Cuong
    Cuong avatar
    4 posts
    Member since:
    Feb 2019

    Posted 24 Feb Link to this post

    This is code in DecimalRound1.cshtml template and Column 'Price' is type double?.

    1.@model double?
    2. 
    3.@(Html.Kendo().NumericTextBoxFor(m => m)
    4.      .HtmlAttributes(new { style = "width:100%", })
    5.      .Decimals(1)
    6.      .Min(0)
    7.)

     

     

     

     

  3. Tsvetina
    Admin
    Tsvetina avatar
    2481 posts

    Posted 27 Feb Link to this post

    Hello Cuong,

    Try calling ToClientTemplate() on the Grid inside the editor template, so its contents are properly escaped for nesting into another widget:
    @(Html.Kendo().Grid<RequestQuoDetailDto>()
            .Name("vendorquodetailGrid")
            ..........................
            .DataSource(dataSource => dataSource
                .Ajax()
                .Group(g => g.Add(f => f.FullGroupName))
                .ServerOperation(false)
                .PageSize(20)
                .Model(model =>
                {
                    model.Id(p => p.QuotationDetailId);
                    model.Field(f => f.PartCode).Editable(false);
                    model.Field(f => f.PartName).Editable(false);
                })
                .Read(read => read.Action("ReadDetailVendorQuo", "PurchaseOrder", new { @area = "Ship" }).Type(HttpVerbs.Post))
        )
        .ToClientTemplate()
    )


    Regards,
    Tsvetina
    Progress Telerik
    Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Back to Top