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

AutoBind(false) not adding a new row when grid is empty

1 Answer 105 Views
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
n/a asked on 17 Jul 2018, 12:00 PM

I'm not sure what am I doing wrong but I'm using Custom Datasoure (API) and adding an authorization header to the request made by the DataSource. Everything works fine but the problem is when the grid is empty I can't add a new row. I was advised to set Autobind(false) from this thread... if I set it to true add new row works fine but I get an Error 401 onload

    .Columns(columns =>
        columns.Bound(p => p.identityType).ClientTemplate("#=identityType.typename#").Width(120);
        columns.Bound(p => p.number).Width(120);
        columns.Command(command => { command.Destroy(); command.Edit(); }).Width(100);
    .ToolBar(toolbar =>
    .Editable(editable => editable.Mode(GridEditMode.InLine))
    .Scrollable(scr => scr.Height(800))
    .Reorderable(reorderable => reorderable.Columns(true))
    .DataSource(dataSource => dataSource
        .Events(events => events
        .Schema(schema => schema.Model(m =>
            m.Id(p => p.identityid);
            m.Field(p => p.identityType).DefaultValue(ViewData["defaultType"] as AdorReactUI.Models.TypeView);
        .Transport(transport =>
            transport.Read(read =>
                  .Type(HttpVerbs.Get)  );
            transport.Create(create =>
            .ContentType("application/json; charset=utf-8") );
For Passing a Token
$(function () {
    var grid = $("#grid").data("kendoGrid"); = Token;
    grid.dataSource.transport.options.create.beforeSend = Token;
    grid.dataSource.transport.options.update.beforeSend = Token;
    grid.dataSource.transport.options.destroy.beforeSend = Token;; // make a DataSource read, which will now use the authorization header
    function Token(xhr) {
        xhr.setRequestHeader('Authorization', "my token");

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 20 Jul 2018, 08:16 AM
Hi Adam,

I tried reproducing the problem in the attached project, but even when the Grid has AutoBind(false) setting, row creation using addRow method works on my side. Could you try modifying my project to reproduce the issue?

Also, one thing that I did not understand from your description is whether the problem is with showing the new empty row in the Grid or with the subsequent save to the server. If there is an issue with showing the new row, then there might be some JavaScript error preventing it. If the row fails to save, I suggest that you check the browser developer tools (F12 key) Network tab to see what is the response from the server after the Grid tries to save the new row.

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.
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question