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

Add new record

2 Answers 125 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Fernando
Top achievements
Rank 1
Fernando asked on 21 May 2015, 09:55 PM

I am a newbie with Kendo and trying to wrap my head around the grid control. Here is what i am trying to accomplish. 

Create a grid to add new records(these will not be sent back to the server at this time)

Be able to delete or edit the records added.

Bound these records with a model

The information on the view will be passed to through the session to a different page and then submitted to the server. The problem i am having is i am only able to add one record. I enter the information and click on add new record again and it wipes out the one i created.

I have attached a pic of how my grid looks like.

Below is my code for the grid. Since i am not passing info to the server i just created dummy create and destroy actions and controller.

 

@(Html.Kendo().Grid<HSBEnrollment.Models.EnrollAccountData>()
    .Name("grid")
    .AutoBind(false)

    .Scrollable(scr => scr.Height(350)) 
    .Editable(editable => editable.CreateAt(GridInsertRowPosition.Top))
    .ToolBar(tbar => tbar.Create())
    .Columns(c => {
        c.Bound(m => m.EnrollAccountsId).Width(150);
        c.Bound(m => m.AccountNum).Width(150);
        c.Bound(m => m.AccountTypeId).Width(150);
        c.Command(command => {  command.Destroy(); }).Width(100);
    })
              
    .DataSource(dataSource => dataSource
    .Ajax()
    .ServerOperation(false)
    .Model(m =>
    {
       
        m.Id(EnrollAccountData => EnrollAccountData.EnrollAccountsId);
        m.Field(EnrollAccountData => EnrollAccountData.AccountNum);
        m.Field(EnrollAccountData => EnrollAccountData.AccountTypeId);
     })
    .Create("IngGrid_Create", "Grid") // <-- dummy action that doesn't exist in controller
    .Destroy("IngGrid_Destroy", "Company") // <-- dummy action that doesn't exist in controller
    )
)

2 Answers, 1 is accepted

Sort by
0
Fernando
Top achievements
Rank 1
answered on 22 May 2015, 11:54 AM
Anybody?
0
Daniel
Telerik team
answered on 25 May 2015, 01:54 PM
Hi,

You should use InCell editing in order to be able to add new rows without synchronizing the changes. When the grid is configured for InLine editing (the default editing mode), the new records should be synced with the server in order to remain in the grid.

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