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

ClientTemplate action button does not render

3 Answers 319 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dan
Top achievements
Rank 2
Dan asked on 22 May 2014, 07:54 PM
I have a grid populated by data from ViewData, and the grid has a column containing an Edit button.  The problem is that the ClientTemplate that defines the Edit button is not showing the input button, rather it just shows the Id number as plain text.  I've used this same Edit button in another grid that is populated by a model, and it works fine.

Any ideas?  Thanks.  Dan
@(Html.Kendo().Grid((IEnumerable<Catheter>)ViewData["catheters"])
            .Name("CatheterGrid")
            .Columns(columns =>
            {
                columns.Bound(e => e.CatheterType.Name).Title("Type");
                columns.Bound(e => e.EffectiveDate).Title("Placed On").Format("{0:d}");
                columns.Bound(e => e.DiscontinuedOn).Title("Discontinued On");
                columns.Bound(e => e.Manufacturer.Name).Title("Manufacturer");
                columns.Bound(e => e.ClinicianDisplayName).Title("Clinician");
                columns.Bound(e => e.Id).Hidden();
                columns.Bound(e => e.Id).ClientTemplate(
                    "<a href='" + Url.Action("EditCatheter", Controllers.Patient) + "/#= Id #'" + "class='btn btn-sm'>Edit</a>"
                    ).Width(80).Title("");
            })
            .Pageable(pageable => pageable
                .PageSizes(true).PageSizes(new int[] { 20, 50, 100 })
                .ButtonCount(5))
            .Sortable()
            .Filterable()
            .Scrollable()
            .ClientDetailTemplateId("template")
            .ToolBar(toolbar =>
            {
                toolbar.Template(@<text>
                    <div style="float:right">
                        <a href='@Url.Action("EditCatheter", Controllers.Patient)/0' class='btn btn-sm'>New</a>
                    </div>
                </text>);
            })
            )

3 Answers, 1 is accepted

Sort by
0
Accepted
Dimiter Madjarov
Telerik team
answered on 23 May 2014, 10:38 AM
Hello Dan,


The current Grid is using a server bound dataSource and it requires server templates too. The ClientTemplate and the ClientDetailTemplate will cause an issue in the current case. You should either use the Template method instead of the ClientTemplate OR add the following configuration to the Grid, so that it uses an Ajax dataSource instead.
E.g.
.DataSource(dataSource => dataSource       
    .Ajax()
    .ServerOperation(false)       
 )

Regards,
Dimiter Madjarov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Dan
Top achievements
Rank 2
answered on 23 May 2014, 12:56 PM
Dimiter,
Thank you. I tried adding the .DataSource lines, but this did not help.
However, I replaced the columns.Bound(e => e.Id).ClientTemplate
with columns.Template(@<text>....
and it works great with a functioning Url.Action.

The thing is, I am fairly new to using the MVC controls, and I don't think that the control parameters are explained very well in either the documentation or the demos.  Using these controls is harder than it should be because of this.

Thanks.
Dan
0
Dimiter Madjarov
Telerik team
answered on 23 May 2014, 01:06 PM
Hello Dan,


I am glad that the current issue is resolved. As for the documentation, we are constantly working on it's improvement, so we could provide the best experience for our customers. Let me know if I could provide you further assistance on the topic?

Regards,
Dimiter Madjarov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Dan
Top achievements
Rank 2
Answers by
Dimiter Madjarov
Telerik team
Dan
Top achievements
Rank 2
Share this question
or