A system error has occurred (More information).

A system error has occurred (More information).

Andy@GAOAndy@GAO Posts: 16Questions: 3Answers: 0

Hi there,

The editor is working until I hit the update button then this appears. I know it's something to do with what is returned
from the server and it should be in json format.

this is my code:

    editor.on('preSubmit', function (e, data, action) {

        if (action === 'edit') {
            var aimDirection = this.field('aimDirection');

            if (!aimDirection.val()) {
                aimDirection.error('An Aim Direction must be entered!');
            }
            else if (aimDirection.val().length > 1) {
                aimDirection.error('The Aim Direction is only 1 character long!');
            }
            else if (aimDirection.val() != 'H' && aimDirection.val() != 'L') {
                aimDirection.error('Aim direction can only be H (high) or L (low)');
            }

            var minValue = this.field('minValue');
            if (!minValue.val()) {
                minValue.error('A Minimum value must be entered!');
            }
            else if (isNaN(minValue.val())) {
                minValue.error('The Minimum value must be a whole number or a decimal');
            }

            var maxValue = this.field('maxValue');
            if (!maxValue.val()) {
                maxValue.error('A Maximum value must be entered!');
            }
            else if (isNaN(maxValue.val())) {
                maxValue.error('The Maximum value must be a whole number or a decimal');
            }

            var greenAmber = this.field('greenAmber');
            if (!greenAmber.val()) {
                greenAmber.error('A Green-Amber value must be entered!');
            }
            else if (isNaN(greenAmber.val())) {
                greenAmber.error('The Green-Amber value must be a whole number or a decimal');
            }

            var amberRed = this.field('amberRed');
            if (!amberRed.val()) {
                amberRed.error('An Amber-Red value must be entered!');
            }
            else if (isNaN(amberRed.val())) {
                amberRed.error('The Amber-Red value must be a whole number or a decimal');
            }

            alert(JSON.stringify(data));

            if (this.inError()) {
                return false;
            }
        }
    });

this is what is produced by the alert:

{"action":"edit","data":{"156":{"aimDirection":"L","minValue":"0","maxValue":"4","greenAmber":"4","amberRed":"5"}}}

What is returned from the server and what do I do to get round this error?

Regards, Andy

Answers

  • tangerinetangerine Posts: 3,342Questions: 35Answers: 394

    What is the actual system error?

  • Andy@GAOAndy@GAO Posts: 16Questions: 3Answers: 0

    The error is:

    "A system error has occurred (More information)."

    at the bottom of the form

    then when I click on the More Information it redirects to:
    https://datatables.net/manual/tech-notes/12

  • tangerinetangerine Posts: 3,342Questions: 35Answers: 394

    ...and what do you get after you follow the instructions in the tech notes?

  • Andy@GAOAndy@GAO Posts: 16Questions: 3Answers: 0
    edited June 2017

    this comes up:
    This is what is displayed when I press the XHR then Response tabs

    C: "d-ECFCF668-Oe,0|On,26|Oo,0"
    M: []

  • allanallan Posts: 61,438Questions: 1Answers: 10,052 Site admin

    Yup - that would do it :). That isn't valid JSON which is why Editor is showing the generic error message and a link to the tech note explaining what it means.

    The question is, why is the server responding with that rather than valid JSON.

    Does the data it is responding with look familiar to you at all?

    Allan

  • Andy@GAOAndy@GAO Posts: 16Questions: 3Answers: 0
    edited June 2017

    Hi Allan,

    I'm going to probably sound really thick now, please bear with me.
    At what point does it make a call to the server and how does it?

        editor = new $.fn.dataTable.Editor({
            "ajax": {
                "url": "/Tables/GetMetricTargetList",
                "type": "POST",
                "dataType": 'json',
            },
                "table": "#metrictargetlist",
                "idSrc": "MetricID",
                "fields": [{
                    label: "Aim Direction:",
                    name: "aimDirection"
                }, {
                    label: "Minimum Value:",
                    name: "minValue"
                }, {
                    label: "Maximum Value:",
                    name: "maxValue",
                }, {
                    label: "Green Amber:",
                    name: "greenAmber"
                }, {
                    label: "Amber Red:",
                    name: "amberRed"
                }
                ]
            });
    

    and does it go back to GetMetricTargetList, because when I place a debug there, it doesn't stop there. The initial call to GetMetricTargetList has
    return Json(dataTableData, JsonRequestBehavior.AllowGet);

    but that populates the grid initially.
    I don't recognise that data string that's returned. Is there a way of ensuring that the right data is returned from the server bearing in mind my above questions.

    Why do I need to get data back from the server at that point? I'm going to put an ajax call there anyway to update my server data with the data in "data" within presubmit - can I disable this data return bit?

    Told yer I'd sound thick!

    Andy

  • allanallan Posts: 61,438Questions: 1Answers: 10,052 Site admin

    HI Andy,

    At what point does it make a call to the server and how does it?

    When the from submits (typically when the user hits the create/edit/delete button inside the form) it will send an Ajax request to the URL given by ajax - in this case /Tables/GetMetricTargetList. The data submitted is in the form described here and Editor expects JSON back in the form also described on that page.

    Does your script expect data and does it save it to the server?

    Why do I need to get data back from the server at that point? I'm going to put an ajax call there anyway to update my server data with the data in "data" within presubmit - can I disable this data return bit?

    Not really. If you are going to submit data anyway, why not just use the regular submit? You can't really do a submit and then tell Editor not to do its own submit.

    You can however manipulate the data that is being submitted by Editor (ajax.data or preSubmit) and also the data being sent back by the server (postSubmit).

    If you don't want Editor to do an Ajax submit at all you can have it just do a local table edit. Which might be what you want?

    Regards,
    Allan

  • Andy@GAOAndy@GAO Posts: 16Questions: 3Answers: 0

    Hi Allan,

    The local table edit is perfect and I'll send a manual ajax call to do the server side stuff
    anyway so problem solved.

    I am puzzled that GetMetricTargetList was never reached although I guess I never arranged the data properly for it to receive properly and never specified params in that ajax call either.

    Anyway many thanks for the help and I'll surely be purchasing the editor license.

    Regards, Andy

  • Andy@GAOAndy@GAO Posts: 16Questions: 3Answers: 0

    Hi Allan,

    I'm wondering if you can help me to get the response from the server working, editor works OK and the server data is updated, but the data in the grid isn't updated so I need this to work.

    As I said, GetMetricTargetList is never reached, am I making a glaring and obvious syntax ommission here? Should it be reached when I hit the UPDATE button on the form?
    And how do I pass jason data back from GetMetricTargetList which I already do?

    Thanks, Andy

  • allanallan Posts: 61,438Questions: 1Answers: 10,052 Site admin

    Should it be reached when I hit the UPDATE button on the form?

    Yes. Have a look in your browser's developer console, are there any errors shown there? If not, are there any requests shown in the Network tab? (you'll need to have the developer tools open for it to see the request).

    Allan

  • Andy@GAOAndy@GAO Posts: 16Questions: 3Answers: 0

    Thanks for that Allan, I'll have a look.

  • dt_userdt_user Posts: 51Questions: 16Answers: 0

    Hi good afternoon. I am experiencing the same problem when I try to edit or create a record using editor. I just want some clarification. To fix this problem editor needs to be linked to the script using ajax option that is connected to the server(database in my case).
    After reading this (https://editor.datatables.net/reference/option/ajax) and this forum I am going to explicitly tell editor what it should do based on an action whether create or edit. because the script file I am using know does not deal with these functionalities.

    Please let me know if my theory is correct and this implementation will work.
    Thank you

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    Hi @dt_user,

    There's a few threads bouncing about here, but yep, if you want to edit server based data, you need to have an ajax script - see the basic example here. If you are experiencing problems still, can we consolidate on your thread here.

    Cheers,

    Colin

This discussion has been closed.