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

[Solved] hasChanges() not available unless SubmitChanges() toolbar used.

3 Answers 97 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
IT
Top achievements
Rank 1
IT asked on 01 Sep 2011, 03:53 AM
I have the following bound to the OnDataBinding event of a grid to check if changes have been saved before refreshing:-

function OnDataBinding(e) {
    var grid = $(this).data("tGrid");
 
    if (grid.hasChanges()) {
        if (!confirm("You are going to lose any unsaved changes. Are you sure?")) {
            e.preventDefault();
        }
    }
}

If I create a grid with the following ToolBar, it works fine:-

.ToolBar(commands =>
{
    commands.SubmitChanges();
})

However if I use a template (so I can include other things in the tool bar):-

.ToolBar(commands =>
{
    commands.Template(@<text>
        <a class="t-button t-grid-save-changes" href="#">Save Changes</a>
        <a class="t-button t-grid-cancel-changes" href="#">Cancel Changes</a>
        @Html.ActionLink("Commit", "Commit", new { id = Model.Id }, new { @id = "buttonCommit", @class = "t-button", @style = "display: none;" })
    </text>);
})

I get a "Object doesn't support this property or method" error on grid.hasChanges(), despite the grid working fine, and the save/cancel changes buttons working as expected.

Is there something in the ToolBar SubmitChanges() extension that adds the hasChanges method to the grid?

3 Answers, 1 is accepted

Sort by
0
Nohinn
Top achievements
Rank 1
answered on 01 Sep 2011, 08:23 AM
The hasChanges function will call to the grid changeLog.dirty() function, this changeLog property will be null unless you enable edition mode InCell.
0
Atanas Korchev
Telerik team
answered on 01 Sep 2011, 10:08 AM
Hi Nohinn,

 This is probably caused by a problem which we recently fixed. You can try downloading the latest internal build where everything should work.

Regards,
Atanas Korchev
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
IT
Top achievements
Rank 1
answered on 02 Sep 2011, 02:01 PM
Thanks for your reply Hohinn.

Irrespective of whether changeLog.dirty() is null, the hasChanges function itself is null in this instance... i.e. hasn't been defined(?)

I should have clarified in my post, but I am using InCell mode, which I mentioned was working (I didn't think I could have SubmitChanges without InCell?)

To summarise the issue:- When in InCell edit mode, the hasChanges function is not defined/available if a ToolBar template is used instead of the standard SubmitChanges button.

I'll take Atanas' direction on this and test with the next build...
Tags
Grid
Asked by
IT
Top achievements
Rank 1
Answers by
Nohinn
Top achievements
Rank 1
Atanas Korchev
Telerik team
IT
Top achievements
Rank 1
Share this question
or