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

Both using editable and template bug...

6 Answers 141 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Andriy
Top achievements
Rank 1
Andriy asked on 29 Feb 2012, 04:22 PM
If I using template and editable.
So when you edit the first record it will automatically set to the value of the latter.

I have for example 3 rows. 
        AAA   |  111
        BBB   |  222
        CCC  |  333

If I click first row. 
My grid will be:
        CCC  |  111
        BBB   |  222
        CCC  |  333

My grid code:
    var locationData = {
        columns:[
          {field: "location", title: "Name"},
          {field: "serial",   title: "Serial Number"}
        ],
        filterable: false,
        sortable: true,
        pageable: true,
        scrollable: false,
        selectable: true,
        editable: true,
        height: 200,
        theme: uiTheme,
        rowTemplate: chargePointRowTemplate,
        dataSource: chargePointsDataSource
    };

var chargePointsDataSource = new kendo.data.DataSource({
    data:restData,
    pageSize:5,
    serverPaging:false,
    serverSorting:false,
    schema:{
        data:function (result) {
            return result.points.testpoints
        },
        total:function (result) {
            if (result.points) {
                return result.points.PageSize;
            } else {
                return result.length || 5;
            }
        },
        model: {
            id: "serial",
            fields: {
                location: { editable: true, type: "string", nullable: true },
                serial: { editable: false, type: "string", nullable: false }
            }
        }
    }
});

var chargePointRowTemplate = kendo.template(
    "<tr><td height='20'>#= location #</td><td height='20'>#= serial #</td><td height='20'><div class='status-item_#= status #'></div></td></tr>"
)

6 Answers, 1 is accepted

Sort by
0
Francesco
Top achievements
Rank 1
answered on 02 Mar 2012, 12:01 PM
Hi, i had the same problem..
i solved it adding the schema: {..... model : { "id": correct value in the datasource schema model specification...
in my case the "id" field was a number type.

Hoping that this solve.

Best regards.
0
Andriy
Top achievements
Rank 1
answered on 02 Mar 2012, 12:09 PM
But I have correct model: {id: "serial" }.
0
Alexander Valchev
Telerik team
answered on 02 Mar 2012, 04:12 PM
Hi Andriy,

You can try to attach the uid as a data attribute to the <tr> element in the template:
For example:
var chargePointRowTemplate = kendo.template("<tr data-uid='#= uid #'><td height='20'>#= ProductName #</td><td height='20'>#= UnitPrice #</td><td height='20'><div class='status-item_#= UnitsInStock #'></div></td></tr>");

I hope this will solve the problem.

Kind regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Jeremy
Top achievements
Rank 1
answered on 28 Mar 2012, 05:58 PM
Hey Alexander 

I'm having a similar issue as the OP, and your input fixed the problem for me.

However, now that I've got your fix, I'm missing the "k-alt" class on every other TR. Any idea how to fix that, or get it back?

Thanks for your help.
0
Jeremy
Top achievements
Rank 1
answered on 28 Mar 2012, 06:02 PM
Alexander,

Sorry. That didn't seem to be the issue after all. The issue only seems to happen when using the template rows. Any ideas how to fix that?

Is that a bug, or something I'm doing wrong?
0
Alexander Valchev
Telerik team
answered on 29 Mar 2012, 03:00 PM
Hi Jeremy,

That is an expected behaviour - the rowTemplate is applied to all rows in the grid and ignores the default "k-alt" classes. There is an altRowTemplate configuration option that you may use to define the structure and style of alternate rows.

$("#grid").kendoGrid({
    rowTemplate: kendo.template($("#rowTemplate").html()),
    altRowTemplate: kendo.template($("#altRowTemplate").html())
    //other configuration
});

I hope this information helps.

Greetings,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Andriy
Top achievements
Rank 1
Answers by
Francesco
Top achievements
Rank 1
Andriy
Top achievements
Rank 1
Alexander Valchev
Telerik team
Jeremy
Top achievements
Rank 1
Share this question
or