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

EditorTemplateName results in empty cell for view

2 Answers 197 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jason
Top achievements
Rank 1
Jason asked on 12 Dec 2016, 08:30 PM

I have the following grid:

@(Html.Kendo().Grid(Model.Items)
                .Name("Items")
                .Columns(columns =>
                {
                    columns.Command(command => command.Custom("-").Click("deleteNominalInvoiceRowItem").HtmlAttributes(new { @class = "button-small", id = "deleteId" })).Width(40);
                    columns.Bound(c => c.Id).Hidden(true).FormClientTemplate("Items", "Items");
                    columns.Bound(c => c.NominalCode)
                        .ClientTemplate("#=NominalCode#")
                        .EditorTemplateName("NominalInvoiceItemAccountCodeTemplate")
                        .FormClientTemplate("Items", "Items");
                    columns.Bound(c => c.Description).FormClientTemplate("Items", "Items");
                    columns.Bound(c => c.NetAmount).HtmlAttributes(new { style = "text-align: right;" })
                        .ClientFooterTemplate("#= gridItemsFooterNetAmount() #").Format("{0:c}").FormClientTemplate("Items", "Items");
                    columns.Bound(c => c.VatAmount).HtmlAttributes(new { style = "text-align: right;" })
                        .ClientFooterTemplate("#= gridItemsFooterVatAmount() #").Format("{0:c}").FormClientTemplate("Items", "Items");
                    columns.Bound(c => c.TotalAmount).HtmlAttributes(new { style = "text-align: right;" })
                        .ClientFooterTemplate("#= gridItemsFooterTotalAmount() #").Format("{0:c}").FormClientTemplate("Items", "Items");
                })
                .HtmlAttributes(new { style = "height: 300px;" })
                .Scrollable()
                .Navigatable()
                .Selectable(x => x.Mode(GridSelectionMode.Single).Type(GridSelectionType.Cell).Enabled(true))
                .Editable(x => x.Mode(GridEditMode.InCell).CreateAt(GridInsertRowPosition.Bottom))
                .ToolBar(x =>
                {
                    x.Create().Text(RCdisplay.Add_Nominal_Invoice_Item);
                    x.Custom().Text(RCdisplay.Clear_All).HtmlAttributes(new { id = "clearItems" });
                })
                .Events(x => x.Edit("onNominalInvoiceItemsGridEdit").Change("onNominalInvoiceItemsGridEdit").Save("onNominalInvoiceItemsGridSave"))
                .DataSource(dataSource => dataSource
                    .Ajax()
                    .Read(read => read.Action("InvoiceItemsGrid_Read", "Invoicing", new { Area = "Invoicing" }))
                    .Create(create => create.Action("InvoiceItemsGrid_Insert", "Invoicing", new { Area = "Invoicing" }))
                    .Update(update => update.Action("InvoiceItemsGrid_Update", "Invoicing", new { Area = "Invoicing" }))
                    .Model(m =>
                    {
                        m.Id(p => p.Id);
                        m.Field(p => p.NominalCode);
                        m.Field(p => p.Description);
                        m.Field(p => p.NetAmount);
                        m.Field(p => p.VatAmount);
                        m.Field(p => p.TotalAmount);
                    })
                    )

 

The EditorTemplateName causes the grid to have an empty cell (it actually contains a hidden field with the value selected) when not in edit mode.

From what i read, the ClientTemplate as I have it should display the value selected.

Is there anything else I need to do to get the selected value displayed as a span when not in edit more?

 

Thanks

2 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 14 Dec 2016, 01:29 PM
Hi Jason,

Indeed, when using a ClientTemplate the content of the template should be render on the page when the grid is in view mode. However, could you please verify that you are not receiving any client exception which might prevent showing the value? Additionally I noticed that you are using a FormClientTemplate method in your case. Is that a custom method since the Bound column does not have such method built-in.

I am looking forward to your reply.

Regards,
Kostadin
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Jason
Top achievements
Rank 1
answered on 14 Dec 2016, 04:00 PM
Thanks for the reply Kostandin, my problem after all was that the name of the autocomplete needed to be the same as the name of the property of the model bound to the grid. As soon as I changed it it started displaying the selected text as a label when not in edit mode.
Tags
Grid
Asked by
Jason
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
Jason
Top achievements
Rank 1
Share this question
or