editor idSrc and ajax Question
editor idSrc and ajax Question
 su33161            
            
                Posts: 7Questions: 5Answers: 0
su33161            
            
                Posts: 7Questions: 5Answers: 0            
            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
1) Editor's
createaction 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