Prevent Customised control buttons in editor to edit all fields in the selectd row

Prevent Customised control buttons in editor to edit all fields in the selectd row

SarbastSarbast Posts: 85Questions: 0Answers: 0

Hello,

I have "Customised control buttons" in the system when the admin click on it to the "Status" field become 'Confirmed' , but the are some fields edit as well and I don't want to. So, how can I prevent these fields th edit when the admin click the customised button.

Regards

Replies

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

    I'm not too clear on the problem, but preOpen may help as it's cancellable. This example demonstrates how it works, preventing editing the Office field if it contains "London".

    If that doesn't help, please can you elaborate on the flow - i.e. are the control buttons per record or would it affect all the records?

    Colin

  • SarbastSarbast Posts: 85Questions: 0Answers: 0

    Hello Colin,

    Here the editor code:

        editor = new $.fn.dataTable.Editor( {
            "ajax": "../../files/includes/controllers/activities.php",
            "table": "#table",
            "fields": [ 
                {
                    "label": "Category:",
                    "name": "staff_activities.category_id",
                    type: "select",
                    placeholder: "Select college",
                    'className': 'full block'
                },{
                    "label": "Activity:",
                    "name": "staff_activities.activity_id",
                    type: "select",
                    placeholder: "Select college",
                    'className': 'full block'
                },{
                    "label": "Status:",
                    "name": "staff_activities.status",
                    "def": "Pending",
                    'className': 'full block'
                }
                
            ]
        } );
    
  • SarbastSarbast Posts: 85Questions: 0Answers: 0

    The Category and Activity are dependent fields. The Status field has default value "Pending", The Admin review the the user's details if correct then will click on "Confirm" button and must the value of "Status" change to "Confirmed" and this works, the value of "Activity" change as well.

    Here the button code

    {
                    extend: "selectedSingle",
                    text: "Confirm",
                    action: function ( e, dt, node, config ) {
                        editor
                            .edit( table.row( { selected: true } ).index(), false )
                            .set( 'staff_activities.status', "Confirmed")
                            .submit();
    
                             
                          }
            },
    
  • SarbastSarbast Posts: 85Questions: 0Answers: 0

    Hello Colin,

    I found the problem and need your help to fix it.
    The problem is because of the "Placeholder".
    If I set "Placeholder" the button unable to change "Status" value and if remove "Placeholder" the button work, but the "Activity" value change with "Status" field.

    Regrds

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

    That sounds odd. Could you link to your page so we can take a look, please,

    Colin

  • SarbastSarbast Posts: 85Questions: 0Answers: 0

    Hello Colin,

    The system in the localhost.

  • SarbastSarbast Posts: 85Questions: 0Answers: 0

    Just if remove placeholder from select the button work, but activity field change as well

  • SarbastSarbast Posts: 85Questions: 0Answers: 0

    with placeholder the button not work

  • SarbastSarbast Posts: 85Questions: 0Answers: 0

    Hello Colin,

    Please check your inbox message because I have send you link for my system

    Regards

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

    Thanks, I tried it, but it appeared to work for me - I was able to confirm and reject those two records.

    I've mocked up a similar setup here, with the a button to set the office to Tokyo - likewise, with placeholder set, it also appears to work. Could you look at that please, and see if you can get that example to behave like you're seeing with your app, as it would help to debug.

    Colin

  • SarbastSarbast Posts: 85Questions: 0Answers: 0

    Hi colin,

    Could you please give the link of that example.

    Regards

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

    Oops, apologies, here it is : http://live.datatables.net/fesocobo/1/edit

    Colin

  • SarbastSarbast Posts: 85Questions: 0Answers: 0

    Thanks Colin for your help. I solved the problem by putting dependent inside if statement.

    Regards

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

    Excellent, glad all sorted,

    Colin

  • SarbastSarbast Posts: 85Questions: 0Answers: 0

    Thanks Colin

Sign In or Register to comment.