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

Kendo Grid Column template renders undefiened

7 Answers 391 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kai
Top achievements
Rank 1
Kai asked on 01 Aug 2012, 06:47 PM
I have this grid on one of my pages
<div id="SearchResults">
        @Html.Kendo().Grid(Model).Name("grdSearchResults").Columns(column=>
        {
            column.Bound(c => c.FormID).Title("Form Number");
            column.Bound(c => c.Country).Title("Country");
            column.Bound(c => c.State).Title("State");
            column.Template(c => @Html.ActionLink(c.Description, "FileBoundGetForm", new { id = c.FormID }, new { @target = "_blank" })).Title("Description");
            column.Bound(c => c.ModifiedUser).Title("Modified User");
            column.Bound(c => c.CreatedDate).Title("Created Date");
        }).DataSource(ds =>
                     ds.Ajax()
                    .Read(reader => reader.Action("DSReleaseForms", "ReleaseForm", new { ByCountry = ViewBag.stateFilter, ByState = ViewBag.countryFilter }).Data("additionalData"))).Pageable()
</div>

My template column renders exactly as it should all good. However i have this on another page
<div id="results">
            @Html.Kendo().Grid(Model).Name("grdClientResults").Columns(column =>
            {
                column.Template(@<text>
                    @Html.ActionLink(@item.ClientID.ToString(), "ClientAdmin", new { id = @item.ClientID })</text>).Title("Edit");//.ClientTemplate("<a href='/ClientAdmin/ClientAdmin/GetClient/#=ClientID#'>#=ClientID#</a>");
                column.Bound(c => c.ClientID).Title("Client Id");
                column.Bound(c => c.Name).Title("Client Name");
                column.Bound(c => c.Address1).Title("Address");
                column.Bound(c => c.Address2).Title("Address2");
                column.Bound(c => c.City).Title("City");
                column.Bound(c => c.StateProvince).Title("State");
                 
            }).DataSource(ds =>
               ds.Ajax()
                        .Read(reader => reader.Action("ClientDetail", "ClientAdmin"))).Pageable()
        </div>
My column template renders 'undefined' as soon as put the template on the column I get this error. has any one else have the problem? I've tried using the clientTemplate as well but the link never postbacks the value and my ID is always null. Can some one point me in the right direction? Thank you in advanced

7 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 06 Aug 2012, 07:55 AM
Hello Kai,

I am not sure what error you get when using the second approach, but here is an help article showing how you can have ActionLink in ajax bounded Grid: http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/faq#how-do-i-use-action-links? 

Regards,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Quynh
Top achievements
Rank 1
answered on 02 Sep 2014, 08:48 PM
Hi,
when I do this

@(Html.Kendo().Grid<RiskBasedModel.CustomClasses.SetupKRI>() //Bind the grid
.Name("setupKRI")
.HtmlAttributes(new { style = "width:98.8%" })
.DataSource(datasource => datasource.Ajax().Read(read => read.Action("GetSetupKRI", "Home").Type(HttpVerbs.Post).Data("filterKRI"))) //.Model(model => model.Id(c => c.STUDY_SETUP_DTL_ID))
.Columns(columns =>
{
// Create a column bound
columns.Bound(kri => kri.KRI_NAME).Title("Name");
columns.Bound(kri => kri.KRI_NAME).Title("Name").Template(@<text>here</text>);
// Create a column bound
columns.Bound(kri => kri.KRI_DESC).Title("Description");
// Create a column bound
columns.Bound(kri => kri.WEIGHT).Title("Weight");
})
//.Pageable() // Enable paging
.Sortable() // Enable sorting
)

"here" will not  show in

.Template(@<text>here</text>)

but when I do this


@(Html.Kendo().Grid<RiskBasedModel.CustomClasses.SetupKRI>(BusinessLayer.DBProcessing.GetSetupKRIs(12345)) //Bind the grid
.Name("setupKRI")
.HtmlAttributes(new { style = "width:98.8%" })
//.DataSource(datasource => datasource.Ajax().Read(read => read.Action("GetSetupKRI", "Home").Type(HttpVerbs.Post).Data("filterKRI"))) //.Model(model => model.Id(c => c.STUDY_SETUP_DTL_ID))
.Columns(columns =>
{
// Create a column bound
columns.Bound(kri => kri.KRI_NAME).Title("Name");
columns.Bound(kri => kri.KRI_NAME).Title("Name").Template(@<text>here</text>);
// Create a column bound
columns.Bound(kri => kri.KRI_DESC).Title("Description");
// Create a column bound
columns.Bound(kri => kri.WEIGHT).Title("Weight");
})
//.Pageable() // Enable paging
.Sortable() // Enable sorting
)

it works

I want to use the datasource read byt I also want the column template so I cand add a textbox to it
0
Nikolay Rusev
Telerik team
answered on 03 Sep 2014, 08:54 AM
Hello Quynh,

You must use ClientTemplate instead. This template will be used when the Grid is ajax bound. Otherwise as in the second scenario you've demonstrated server binding will be performed and Template setting will be used.

Regards,
Nikolay Rusev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Quynh
Top achievements
Rank 1
answered on 03 Sep 2014, 04:13 PM
The reason I have to use Ajax bound because I have a dropdownlist that when the dropdownlist selected value changed the grid will  be populated according to the selected dropdown item. I notice that the client bound seems slower than the server bound. Is there any sample that achieve the samething but with the server bound method?
0
Nikolay Rusev
Telerik team
answered on 08 Sep 2014, 08:22 AM
Hello Quynh,

With server bound mode the Grid is bound on server and then rendered, while with ajax mode the grid basic structure and initialization scripts are rendered when the page is loaded it will request data from server. That said the binding speed will depend on how fast server code for processing data and request is returned.

The following demo illustrates something which seems similar to what you've described: grid toolbar template.

Regards,
Nikolay Rusev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Quynh
Top achievements
Rank 1
answered on 08 Sep 2014, 04:32 PM
But your example is client AJAX bound. I am asking if you have the same thing but server bound. I want to know if there is such thing like that if there is none then I don't have to  continue searching.
0
Nikolay Rusev
Telerik team
answered on 11 Sep 2014, 07:13 AM
Hello Quynh,

We don't have example demonstrating the scenario with server binding. Implementing server binding in this case will require submitting of form to server, collecting (submitted) data on server, binding the grid and posting back the whole page.

Regards,
Nikolay Rusev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Kai
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Quynh
Top achievements
Rank 1
Share this question
or