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

Add new record in the grid along with a serial number

1 Answer 370 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Vijay
Top achievements
Rank 1
Vijay asked on 09 Oct 2013, 10:59 AM
Hi,
   I have a requirement which is as follows.
   I would want to add new rows to the grid and there should be a serial number which should get incremented automatically. Please let me know whether this can be achieved in Kendo grid. I am working on the HTML version and not on the MVC version. A sample in the HTML version would be great.
Regards,
Vijay

1 Answer, 1 is accepted

Sort by
0
Accepted
Alexander Popov
Telerik team
answered on 09 Oct 2013, 12:30 PM
Hello Vijay,

Yes, this behavior could be achieved. I would recommend using the Grid's edit event to set the new Model's serial number field. Here is an example:  
$("#grid").kendoGrid({
     edit: function(e) {
      if (e.model.isNew()) {
        var newSerialNumber= "1234"; //generate the new Serial number in the best suitable for you project way
        e.model.set("SerialNumber", newSerialNumber);
      },
      ...
}

Regards,
Alexander Popov
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
Vijay
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Share this question
or