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

Inline editing remains open after insert

2 Answers 53 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Catherine
Top achievements
Rank 1
Catherine asked on 17 Jul 2018, 05:54 PM

I have a grid that successfully inserts and deletes, however, after I perform an insert the inline edit remains open. If I hit cancel it does not display the new data; I have to refresh the page to see it in the grid.

Here is my code:

<div class="k-grid">
    @(Html.Kendo().Grid<GasModel>()
                .Name("manageGasesGrid")
                .AutoBind(true)
                .Columns(columns =>
                {
                    columns.Bound(p => p.gasName).Title("Name");
                    columns.Bound(p => p.formula).Title("Formula");
                    columns.Bound(p => p.gasID).Title("ID").Hidden();
                    columns.Command(command => { command.Edit(); command.Destroy(); }).Width(190);
                })
                .Events(e => e
                    .Edit("onEdit")
                )
                .ToolBar(toolbar => toolbar.Create())
                .Editable(editable => editable.Mode(GridEditMode.InLine))
                .Sortable(sortable => sortable.SortMode(GridSortMode.MultipleColumn))
                .Filterable()
                .Reorderable(r => r.Columns(true))
                .ColumnMenu()
                .Scrollable(s => s.Endless(true))
                .DataSource(dataSource => dataSource
                    .Ajax()
                    .Model(model => model.Id("gasID"))
                    .ServerOperation(false)
                    .Read(read => read.Action("Gases_ReadAsync", "Gas"))
                    .Create(create => create.Action("Gases_CreateAsync", "Gas", "gasData"))
                    .Update(update => update.Action("Gases_UpdateAsync", "Gas", "gasData"))
                    .Destroy(destroy => destroy.Action("Gases_DestroyAsync", "Gas", "gasData"))
                )
    )
</div>

 

<script>
 
    function gasData(e) {
        return {
            gasID: id,
            gasName: name,
            formula: gasFormula
        }
    }
    function onEdit(e) {
        var id = this.gasID
        var name = this.gasName
        var gasFormula = this.formula
    }
 
</script>

2 Answers, 1 is accepted

Sort by
0
Accepted
Tsvetina
Telerik team
answered on 20 Jul 2018, 09:19 AM
Hi Catherine,

Such behavior could be observed if there is something wrong with the response from the Create method in the controller. Could you show us what the Create method looks like in your project? Also, you could try inspecting the response on the client by following these steps:
1. Open the browser developer tools (F12 key) Network tab.
2. Try to insert a records. This will produce a request to the Create method and you will see it logged in the developer tools.
3. Inspect the logged request to see what is its response.
4. Send us a copy or a screenshot of the response content.

By default, the Create method should return the newly created item with the Id assigned to it on the server: screenshot

Regards,
Tsvetina
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.
0
Catherine
Top achievements
Rank 1
answered on 24 Jul 2018, 12:01 PM

Hi Tsvetina,

You are right, I am not getting a proper response back from my controller. I'm going to do some further investigating. I'm also having similar problems with another grid. If I need further help I will open a ticket.

Thank you!

Tags
Grid
Asked by
Catherine
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Catherine
Top achievements
Rank 1
Share this question
or