display id in editor

display id in editor

montoyammontoyam Posts: 568Questions: 136Answers: 5

I added the ID field as read-only to the editor

{ "label": "SubmissionID:", "name": "Submissions.SubmissionID" , type:"readonly" },

but I am getting the error:
Cannot update identity column 'SubmissionID'.

Is it not possible to view the ID field in the editor?

This question has accepted answers - jump to:

Answers

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

    That should work, I modified this example locally to contain:

                }, {
                    label: "id:",
                    name: "DT_RowId",
                    type: "readonly"
                }, {
    
    

    and that gave the read-only ID on the form as expected, with no errors on edit or create.

    Are you able to link to your page so we can take a look?

    Colin

  • montoyammontoyam Posts: 568Questions: 136Answers: 5
    edited March 2020

    sorry, the page is on our intranet.

  • colincolin Posts: 15,118Questions: 1Answers: 2,583
    Answer ✓

    This thread has the same error, so it would be worth checking Allan's comments there.

    Colin

  • montoyammontoyam Posts: 568Questions: 136Answers: 5

    Yes, that was it exactly! Thank you.

    asp.net - in my controller:

                        .Field(new Field("Submissions.SubmissionID")
                            .Set(false)
                        )
    
  • montoyammontoyam Posts: 568Questions: 136Answers: 5

    I just stumbled upon what appears to be a different solution.

    https://editor.datatables.net/reference/option/fields.submit

            {
                label: 'Created:',
                name: 'created',
                type: 'readonly',
                submit: false, // Value shown for information only. Server will create a real time stamp
                def: function() {
                    return new Date().toISOString();
                }
            }
    

    Is there any advantage of doing it one way over the other (controller vs. javascript)?

  • colincolin Posts: 15,118Questions: 1Answers: 2,583
    Answer ✓

    The controller would be more secure - it's always best to sanitise the data nearest the database, as less change of people finding ways to circumvent. Other than that, I don't think it matters too much,

    Colin

This discussion has been closed.