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

Automatically save changes instead of discard changes on an AJAX Grid?

3 Answers 406 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Samuel
Top achievements
Rank 2
Samuel asked on 06 Mar 2013, 10:54 PM
I have an ajax grid with several pages of data that I allow users to perform CRUD operations on using the InCell edit mode. However, if I change pages or ordering or manipulate the page in any way after making a change the default behavior is to discard changes. I've noticed that if I set .ServerOperations(false), I can navigate without losing my changes but I also lose the 'dirty mark' indicating that there have been changes. This is likely to cause users to navigate away from the page and lose those changes with no feedback from the page. While that can still happen with a dirty mark, the client has decided that they would prefer that any changes be saved prior to changing pages or filtering (basically, any of the _Read events).

What is the best way to enable a save operation prior to losing data in such a grid? 

3 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 08 Mar 2013, 12:48 PM
Hi Samuel,

 
The best practise is to enable the autoSync option of the dataSource which will automatically save changes after each change.

Kind Regard,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Samuel
Top achievements
Rank 2
answered on 08 Mar 2013, 10:37 PM
The problem is that the documentation you link to only seems to apply to Kendo Web - I don't see an MVC framework component that implements (or even mentions) Autosync. I've checked the API documentation specific to the various Datasource components with no success. I'm sure I'm missing it somewhere, but Intellisense has also failed me so far. Here's the view I'm concerned with:
@(Html.Kendo().Grid(Model)
    .Name("IndexGrid")
    .Columns(col =>
    {
        col.Bound(c => c.SchoolYear);
        col.Bound(c => c.SubmissionTypeDesc);
        col.Bound(c => c.EntityDesc);
        col.Bound(c => c.SubmissionDate);
        col.Bound(c => c.UserName);
        col.Command(c =>
            {
                c.Custom("Edit")
                    .Text("Map Balance Sheets")
                    .Action("CreateBalSheetMap", "Draft");
                c.Custom("ReMap")
                    .Text("Detect Template")
                    .Action("ReMapBalSheets", "Draft");
            }
            ).Title("<b>Actions</b>");
    })
    .DataSource(ds =>
    {
        ds.Server()
        .Model(model => model.Id(pk => pk.snapshot_id));
    }
        )
    .Sortable(sort => sort.Enabled(true).SortMode(GridSortMode.MultipleColumn).AllowUnsort(true))
    .Reorderable(reorder => reorder.Columns(true))
    .Groupable(group => group.Enabled(true))
    )
0
Vladimir Iliev
Telerik team
answered on 12 Mar 2013, 03:28 PM
Hi Samuel,

You are correct - currently changing the autoSync option of the grid is not possible using the HTMLHelper, however you can set it using the code below which must be executed before the grid initialization:

<script>
    kendo.data.DataSource.prototype.options.autoSync = true;
</script>
Kind Regards,
Vladimir Iliev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Samuel
Top achievements
Rank 2
Answers by
Vladimir Iliev
Telerik team
Samuel
Top achievements
Rank 2
Share this question
or