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

Pass Model to column ClientTemplate editor in Grid

1 Answer 376 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
GCS asked on 02 Jul 2014, 11:50 PM
I have a grid whereas the columns are defined as: 

.Columns(columns =>
    columns.Bound(b => b.Field);
    columns.Bound(b => b.OldValue);
    columns.Bound(b => b.NewValue);
    columns.Bound(b => b.DateImported).Format("{0:dd-MMM-yyyy}");
    columns.Bound(b => b.BuildingChangeValidationStatusType).ClientTemplate("#=BuildingChangeValidationStatusType.Value#").Width(250);
    columns.Command(command => command.Custom("Update").Click("updateValidation"));
    columns.Command(command => { command.Edit(); }).Width(172);

The BuildingChangeValidationStatusType client template is defined as: 

@model Rep.Models.BuildingChangeValidationViewModel
    .Name("BuildingChangeValidationStatusType") // Name of the widget should be the same as the name of the property

I am wanting to pass the model for each row to the client template since each row will contain its own lookup values.  How can I accomplish this? 

1 Answer, 1 is accepted

Sort by
Vladimir Iliev
Telerik team
answered on 07 Jul 2014, 07:13 AM
Hi Dave,

From the provided information it's not clear for us what exactly you are trying to achieve and what is the current Grid configuration that you are using, however if you need to filter the DropDownLists based on current model than you can use the following approach:
- Set DataBound event handler:
.Events(e => e.DataBound("dataBound"))

- Add the event handler before DropDownList initialization code:
    var globalFlag = false;
    function dataBound(e) {
        //execute only once
        if (!globalFlag) {
            var row = this.wrapper.closest("tr");
            var grid = row.closest("[data-role=grid]").data("kendoGrid");
            var model = grid.dataItem(row);
            globalFlag = true;
            this.dataSource.filter({ field: "Text", operator: "startswith", value: "Ax" });

Vladimir Iliev

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.

Asked by
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Share this question