Standalone Editor idSrc

Standalone Editor idSrc

MadwikMadwik Posts: 4Questions: 2Answers: 0

Hello,

I've become a huge fan of DataTables and I'm using extensively in a project with many editable tables. I like it so much, that I want to use the Standalone Editor for a couple of sections.

Is there an idSrc option when using the Standalone Editor, or another way to do something similar? Obviously, I don't want the ID field to be editable. Should idSrc work with the Standalone Editor, or do I need to find another way to send the ID with the request?

I have the following code:

dd_editor = new $.fn.dataTable.Editor( { 
        ajax: "/orders/_com/json.cfc?method=editJson&Com=Order&Req=OrderMaster",
        idSrc: "id",
        fields: [{
            name: "id" // IDEALLY THIS FIELD WILL NOT BE HERE
            }, {
                name: "client_po_number"
            }, {
                name: "payment_status",
                type:  "select",
                options: [ "Not Due and Unpaid","Due and Unpaid","Paid","Cancelled" ]
            }, {
                name: "submitted",
                type:  "select",
                options: [ "In Process","Completed","Cancelled" ]
            }, {
                name: "orderduedate"
            }, {
                name: "billingdate"
            }, {
                name: "comments"
            }
        ]
    } );

Response:

action:edit
data[id]:21 //Should not appear here, either.
data[client_po_number]:12345
data[payment_status]:Paid
data[submitted]:Completed
data[orderduedate]:05/10/2011
data[billingdate]:01/01/1970
data[comments]:edited 3

In my response, I am receiving the data array, but the "id" field does not appear outside of data[]. If I'm using idSrc in a standard table implementation, the "id" field does appear.

Note: Currently, the ID field appears on the form (which is why it's in the fields set above), but I need a way to hide it so that it's not accidentally changed.

Any assistance or clarification on the issue is greatly appreciated.
Thank you!

This question has an accepted answers - jump to answer

Answers

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

    idSrc is only designed to be relevant for collections, so it isn't particularly useful for a standalone Editor which is designed for single entities.

    However, what you should be able to do is, where you call edit() on a standalone editor is just pass the value you want to be the ID into the function:

    editor.edit( 21 );
    

    The value given there will be passed through as the id value submitted to the server.

    Allan

  • MadwikMadwik Posts: 4Questions: 2Answers: 0

    Thank you, Allan! I appreciate the info, along with all of your other helpful responses that have been a great resource for me.

This discussion has been closed.