0

I needed to append a new row to a kendo grid at the bottom, on pressing a button but I have a template defined for one of the columns and getting error in that template saying "Cannot read property 'replace ' of undefined".

Here is the code that i am trying to use for the above operation:

var dataSource = grid.dataSource;
var total = dataSource.data().length;
dataSource.insert(total, {});
dataSource.page(dataSource.totalPages());
grid.editRow(grid.tbody.children().last());

I want the new grid in editable mode.Any kind of help please

touchStone
  • 317
  • 2
  • 16
  • Check Here:[http://stackoverflow.com/questions/23354554/uncaught-typeerror-cannot-read-property-replace-of-undefined-in-grid](http://stackoverflow.com/questions/23354554/uncaught-typeerror-cannot-read-property-replace-of-undefined-in-grid) – Skull Jan 27 '16 at 13:33

1 Answers1

0

I believe that 'replace' is one of field in yourdataItem? You have to define all new row default values while grid creation:

$("#grid").kendoGrid({
    dataSource: {
        data: data,
        schema: {
            model: {
                fields: {
                    replace: {
                        defaultValue: "your value",
                    }
                }
            }
        }
    }
...
});

or when you insert new row:

dataSource.insert(total, { replace : "your value" });
Jarosław Kończak
  • 3,387
  • 2
  • 19
  • 36
  • thank you for ur reply, but i have found the answer myself.I missed specifying the dummy json object row , matching the grid record i.e {'field1': '', 'field2': '', ..} was required to apply replace(via template) on the intended field - so that it :) – touchStone Oct 27 '14 at 18:26