question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[HELP WANTED] How can I prevent clearing the insert boxes on fail?

See original GitHub issue

Hello,

I have read the issue #190 and was able to replicate it. I’m using the PageLoadingStrategy and want to prevent grid from clearing the insert boxes on fail. I have replaced the finishInsert function. image image

But even after return something clears the insert boxes. I want to keep input values there and allow user to fix them instead of the typing them again.

Thank you!

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
tabalinascommented, Oct 13, 2016

https://github.com/tabalinas/jsgrid/blob/3ca96b5d87a417e1a64ef04bfc689e90ef2b6d3a/src/fields/jsgrid.field.control.js#L182

Basically, it’s not a load strategy that clears the insert row, but the control field (insert button handler). So you can redefine the handler of this button, or just reject the insertion deferred instead of resolving it in case of failure.

0reactions
deepak-trimantracommented, Dec 22, 2016

Hi @tabalinas can we do this for update also? as you suggested i redefined insert and update button controller. For inserting when insert fails it prevents from clearing inputs. But i am not able to achieve this in case of update. When update fails if resolves previousItem but i want to do same as insert, don’t want to clear the input.

**UPDATE FUNCTION :**
updateItem: function (updatingItem) {
                var d = $.Deferred();
                $.ajax({
                    url: url
                    type: "POST",
                    data: updatingItem,          
                }).done(function (response) {
                    display_notification(obj);
                    if (obj.flag)
                    {
                        grid.updateFailed = false;
                        d.resolve(response.data);
                    } else
                    {
                        grid.updateFailed = true;
                        d.resolve(previousItem);
                    }
                }).fail(function () {
                    d.resolve(previousItem);
                });
                return d.promise();

**EDIT CONTROL**
function getCustomEditControls() {
    return $("<input>").addClass("jsgrid-button")
            .addClass("jsgrid-update-button")
            .attr({
                type: "button",
                title: "Save"
            })
            .on("click", function () {
                grid2.updateItem().done(function () {
                    if (!grid.updateFailed)
                    {
                        grid2.clearInsert();
                        clear_errs();
                    }
                    else
                    {
                        grid.jsGrid("cancelEdit");  //???? nothing happens
                    }
                }).fail(function () {
                    grid.jsGrid("cancelEdit"); //??? nothing happens
                });
            })
            .add($("<input>")
                    .addClass("jsgrid-button")
                    .addClass("jsgrid-cancel-edit-button")
                    .attr({
                        type: "button",
                        title: "Cancel"
                    })
                    .on("click", function () {
                        if (!grid2.insertings)
                        {
                            grid.jsGrid("cancelEdit");
                        }
                    }));
}

can you help me out here?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Lock or unlock specific areas of a protected worksheet
Click the Protect Sheet button to Unprotect Sheet when a worksheet is protected. If prompted, enter the password to unprotect the worksheet. Select...
Read more >
Excel Data Validation Tips and Troubleshooting - Contextures
Click the Developer tab on the ribbon, and click Insert; Click the Combo Box in the Form Controls; On the worksheet, drag to...
Read more >
Get help if you are unable to pay for storage - Google One Help
Under "Clean up space," click View. Under the category that you want to manage, click Review and clean up. Select the files that...
Read more >
Data validation in Excel: how to add, use and remove - Ablebits
Among other things, you may want to allow only particular data type such as ... Check the Show error alert after invalid data...
Read more >
Excel VBA Error Handling - All You Need to Know!
Insert Message Box at some place in the code and highlight values/data that can help understand if eberything is going as expected. Instead...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found