Handling messages in CollectionViewItemResult<T>.Error

Posted by: elogsdon on 5 August 2020, 2:10 am EST

    • Post Options:
    • Link

    Posted 5 August 2020, 2:10 am EST

    I am using FlexGrid in an ASP.Net MVC application with Excel style Editing (server side). I am using https://www.grapecity.com/componentone/docs/mvc/online-mvc/FlexGridExcelStyleEditing.html as my model.

    The GridUpdate, GridDelete and GridCreate routines return error messages as part of the CollectionViewItemResult. When there are messages they are shown via an alert message. Is there anyway to change that behavior so I can display them in a control or tool tip?

    Thanks,

    Eric

  • Posted 5 August 2020, 8:53 pm EST

    Hello Eric,

    For this, we need to handle the onError event for editableCollectionView which causes the issue for the JS alert.

    You may handle this event to show Custom Error message. If you would like to show Success/Error message both, you should handle the OnClientQueryData event. Please refer to the following code snippet for refernce:

    <script>
        function Complete(s, e) {
            console.log("OnQueryComplete", e.result.operatedItemResults[0])
        }
        function fixDefaultJSAlert() {
            var grid = wijmo.Control.getControl("#TestGrid");
            // User can write his own error handling for preventing the first javascript alert
            grid.editableCollectionView.onError = function (error) {
                // do what you want
                console.log("OnError",error);
                return false;
            };
        }
    </script>
    @(Html.C1().FlexGrid().Id("TestGrid")
                    .AutoGenerateColumns(false)
                    .Bind(m=>m.Bind(Model.Data).Update(Url.Action("GridUpdate", "Home")).OnClientQueryComplete("Complete"))
                    .Height(200)
                    .Columns(cb =>
                    {
                        cb.Add().Binding("ID");
                        cb.Add().Binding("First");
                        cb.Add().Binding("Last");
                        cb.Add().Binding("Sales");
                        cb.Add().Binding("Hired");
                        cb.Add().Binding("CountryID");
                        cb.Add().Binding("Active");
                    })
                    .OnClientLoadedRows("fixDefaultJSAlert")
    )
    
    

    Regards,

    Manish Gupta

  • Posted 7 August 2020, 12:54 am EST

    Thanks.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels