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

[Solved] How to add new record to grid?

3 Answers 3040 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Michail
Top achievements
Rank 1
Michail asked on 16 Jan 2013, 02:43 PM
Hello, i have a grid and i want to be able to add new record by button

$("#grid").kendoGrid({
height: 206,
editable: true
dataSource: {
    data: [ { lt_time: "00:00", lt_event: "Test message" } ]
},
columns: [ { width: 60, field: "lt_time", title: "Time" }, { field: "lt_event", title: "Event" } ]
});

Delete works fine:
var grid = $("#grid").data("kendoGrid"); 
grid.removeRow(grid.tbody.find(">tr:first"));
but how to add new entry? something like: 
grid.addRow( { lt_time: "00:00", lt_event: "Test Message" } );

thanks for answers!




3 Answers, 1 is accepted

Sort by
0
Iliana Dyankova
Telerik team
answered on 17 Jan 2013, 11:00 AM
Hello Michail,

In order to add a new item you can use the DataSource's add() method and the create transport to synchronize the changes. For example: 
var dataSource = $('#grid').data('kendoGrid').dataSource;
dataSource.add({lt_time:"00:00",lt_event:"Test Message"});

Regards,
Iliana Nikolova
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Richard
Top achievements
Rank 1
answered on 16 Dec 2014, 07:37 PM
Can you provide a example of what that datasync change is?  What happens after addrow then datasync then display in grid?
0
Iliana Dyankova
Telerik team
answered on 18 Dec 2014, 01:13 PM
Hi Richard,

It appears my colleague Peter has already answered to a similar question in the support thread you opened (889522). I would like to ask to continue the discussion in the support thread in order to avoid any duplications. Thank you in advance for your understanding and cooperation.

Regards,
Iliana Nikolova
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
Michail
Top achievements
Rank 1
Answers by
Iliana Dyankova
Telerik team
Richard
Top achievements
Rank 1
Share this question
or