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

4 posts, 0 answers
  1. Samuel
    Samuel avatar
    19 posts
    Member since:
    Aug 2012

    Posted 06 Mar 2013 Link to this post

    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? 
  2. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 08 Mar 2013 Link to this post

    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!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Samuel
    Samuel avatar
    19 posts
    Member since:
    Aug 2012

    Posted 08 Mar 2013 Link to this post

    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))
        )
  5. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2172 posts

    Posted 12 Mar 2013 Link to this post

    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!
Back to Top
UI for ASP.NET MVC is VS 2017 Ready