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

Client Template in GRID

3 Answers 1438 Views
Grid
This is a migrated thread and some comments may be shown as answers.
JP
Top achievements
Rank 1
JP asked on 21 May 2018, 04:52 PM

I am Migrating the app from MVC 5 to Core 2.0. We are facing issue with the grid client template as we are unable to use it when we use it along with the editable property. Following is the code.

01.@(Html.Kendo().Grid<PPVR>()
02.                                                .Name("PPVRGird")
03.                                                .Columns(columns =>
04.                                                {
05.                                                    columns.Bound(e => e.id).Hidden();
06.                                                    columns.Bound(c => c.name);
07.                                                    columns.Bound(c => c.quantity);
08.                                                    columns.Bound(c => c.type);
09.                                                    columns.Bound("").ClientTemplate("<div style='text-align:center'><a href='javascript:void(0)' class='k-grid-edit custom-action-button'onclick='customGridEditClick(this)'><img src='/Content/edit.svg' width ='40' height='40'/><br/>Edit</a></div>").HeaderHtmlAttributes(new { @class = "custom-action-button" }).Title("Edit").Width(150);
10.                                                    columns.Bound("").ClientTemplate("<div style='text-align:center'><a href='javascript:void(0)' class='custom-action-button pull-center' onclick='deleteppvr(#=id#)'><img src='/Content/trashed.svg' width='40' height='40' /><br />Delete</a></div>").HeaderHtmlAttributes(new { @class = "custom-action-button" }).Width(200);
11.                                                })
12.                                                    .Pageable()
13.                                                    .HtmlAttributes(new { style = " text-align:left; font-family:lato; font-zize:16px; " })
14.                                                    .DataSource(dataSource => dataSource
15.                                                    .Ajax()
16.                                                    .PageSize(100)
17.                                                    .Read(read => read.Action("GetPPVR", "PPV"))
18.                                                    .Model(model =>
19.                                                    {
20.                                                        model.Id(u => u.id);
21.                                                        model.Field(u => u.type).Editable(false);
22.                                                    })
23.                                                    .Update(update => update.Action("UpdatePPVR", "PPV"))
24.                                                    )
25. 
26..Editable(editable => editable.Mode(GridEditMode.InLine))
27. 
28.                                            )
29. 
30.

This brings the empty page. When I comment the line .Editable(editable => editable.Mode(GridEditMode.InLine)) page appears. It works well in MVC 5 but not in core 2.0.

Kindly suggest how can I achieve this.

3 Answers, 1 is accepted

Sort by
0
JP
Top achievements
Rank 1
answered on 22 May 2018, 03:18 AM

Sample Project for replication 

https://drive.google.com/file/d/1QFE9R1xvjHxCDYFA2TsufYFIRR_8CFeq/view?usp=sharing

0
JP
Top achievements
Rank 1
answered on 22 May 2018, 06:44 AM
UPDATE => This issue is coming only when I am using Inline option for editing when I use Pop Up then it works fine.
0
Preslav
Telerik team
answered on 24 May 2018, 10:54 AM
Hello JP,

A possible solution is to bind the desired columns to any field, and using the columns.editable configuration to prevent editing for these columns. 
For example:

columns.Bound(p => p.Freight).ClientTemplate("Hi").HeaderHtmlAttributes(new { @class = "custom-action-button" }).Width(200).Editable("function(){return false;}");
columns.Bound(p => p.Freight).ClientTemplate("Bye").HeaderHtmlAttributes(new { @class = "custom-action-button" }).Title("Sample").Width(150).Editable("function(){return false;}");

I hope this helps.


Regards,
Preslav
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
JP
Top achievements
Rank 1
Answers by
JP
Top achievements
Rank 1
Preslav
Telerik team
Share this question
or