display id in editor

display id in editor

montoyammontoyam Posts: 162Questions: 40Answers: 3

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: 8,150Questions: 0Answers: 1,364

    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: 162Questions: 40Answers: 3
    edited March 25

    sorry, the page is on our intranet.

  • colincolin Posts: 8,150Questions: 0Answers: 1,364
    Answer ✓

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

    Colin

  • montoyammontoyam Posts: 162Questions: 40Answers: 3

    Yes, that was it exactly! Thank you.

    asp.net - in my controller:

                        .Field(new Field("Submissions.SubmissionID")
                            .Set(false)
                        )
    
  • montoyammontoyam Posts: 162Questions: 40Answers: 3

    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: 8,150Questions: 0Answers: 1,364
    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

Sign In or Register to comment.