editor idSrc and ajax Question

editor idSrc and ajax Question

su33161su33161 Posts: 7Questions: 5Answers: 0
edited June 2018 in Free community support

1)Question.
I'm making an create editor button.
I have not created any data yet, so SN is null.
click the create button, {[ {"SN":"-1", ......} ]} This information is passed on.
I guess that's because the fields values are created after idsrc is applied.
I hope {"-1":{"SN":"-1", ......}} This information is passed on.

2)Question.
The return value of the editor is always an error value.
I saw a document that if the value is not json, the error value is always generated.
My return value is this value of Request.CreateResponse (HttpStatusCode.OK). What should I do?

Thank you for reading this Question

var editor = new $.fn.dataTable.Editor({
    "ajax":{
        "url": "...",
        "type": "POST",
        "datatype":'json',
        error:function(){
        ....
        }
    [.....]
    table: "#demoGrid",
    idSrc: 'SN',
    fields:[
    {
        label:"SN",
        name:"SN",
        def:-1},
    {....}
    ]
);

var table = $(#demoGrid").DataTable({
    .....
    buttons:[
        { extend:"create", editor: editor}
    ],
    .....
    "columun":[
        { "data": "SN", "name": "SN"},
        {...}
        ]
    });

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Answer ✓

    1) Editor's create action will number new rows starting from 0 (it can create multiple new rows at a time). It does not take the value of a field that is entered by the end user I'm afraid - that is not configurable.

    2) You need to return valid JSON. The documentation for what should be returned is here.

    Allan

This discussion has been closed.