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

Form submitted multiple times

3 Answers 53 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.
Muhamad Tassadaque Zia
Top achievements
Rank 1
Muhamad Tassadaque Zia asked on 24 Nov 2011, 11:33 AM
I am using telerik mvc grid with editing. I am getting issue. My user is pressing the submit button multiple times and duplicate records get inserted. One solution would be to use javascript to disable button after one click. but looking for a solution at server side. 
Thanks

3 Answers, 1 is accepted

Sort by
0
Muhamad Tassadaque Zia
Top achievements
Rank 1
answered on 19 Dec 2011, 08:31 AM
Any update in this regard?
0
Dave
Top achievements
Rank 1
answered on 12 Jan 2012, 08:06 AM
This is a HUGE problem for me too. We have a grid with sparse data -- the rows are actually only created the first time data is submitted for them, so we end up with multiple rows on first-time happy clickers. On row updates, we don't end up with data issues -- but the problem remains that allowing multiple postbacks at the same time for data is BROKEN in an ansynchronous model.

Please fix this Telerik. In the mean time, I'm going to have to work around this in my own javascript code ): I can't believe this made it through testing at Telerik -- I found this bug in my own testing with only a few hours' exposure to the grid.
0
Dave
Top achievements
Rank 1
answered on 12 Jan 2012, 09:40 AM
Update: Telerik stuff is currently broken in this regard. However, with a little jQuery, you can do:


function showFakeButtons(HostGridID) {
// generates fake buttons to mimick those of telerik
    var toolbarSelector = "#" + HostGridID + " > .t-toolbar";
    if ($(".fake-telerik").length == 0) {
        $(toolbarSelector).children().each(function () {
            $(toolbarSelector).append($(this).clone().addClass("fake-telerik").css("opacity", "0.5").css("pointer","not-allowed"));
        });
    }
    $(toolbarSelector).children().each(function () {
        if (!$(this).hasClass("fake-telerik")) {
            $(this).hide();
        } else {
            $(this).show();
        }
    });
}




function showRealButtons(HostGridID) {
    var toolbarSelector = "#" + HostGridID + " > .t-toolbar";
    $(toolbarSelector).children().each(function () {
        if ($(this).hasClass("fake-telerik")) {
            $(this).hide();
        } else {
            $(this).show();
        }
    });
}


// attach this to your grid's OnSubmit event
function onGridSubmit(e) {
    showFakeButtons("Put_Your_Grid_ID_Here");
}


// attach this to your grids OnComplete event
function onGridComplete(e) {
    showRealButtons("Put_Your_Grid_ID_Here");
}


//--
Here's hoping someone at Telerik fixes this. It's well broken.

Tags
Grid
Asked by
Muhamad Tassadaque Zia
Top achievements
Rank 1
Answers by
Muhamad Tassadaque Zia
Top achievements
Rank 1
Dave
Top achievements
Rank 1
Share this question
or