Editor readonly field not works

Editor readonly field not works

allenstyleallenstyle Posts: 4Questions: 1Answers: 0

Hi,

I tried to set a field as readonly, but it's not working.
It's still editable. And I use Editor with inline mode.
See snip of code as below:

editor = new $.fn.dataTable.Editor({
             fields: [
                      {
                          type: "readonly",
                          label: "product.productNumber:",
                          name: "product.productNumber",
                      });

dataTable = $('#grid').DataTable({
                  "dom": "Bfrtip",
                  "columns": [
                      { "data": "product.productNumber" }
                  ]
                   });

Thank you,

Allen Tsai

Answers

  • colincolin Posts: 15,146Questions: 1Answers: 2,586

    Hi @allenstyle ,

    This is working as expected for me here. The inline activates but editing isn't permitted - to prevent inline, you can change the selector to be

      $('#example').on('click', 'tbody tr td:not(:first-child)', function() {
        editor.inline(this);
      }); 
    

    Hope that helps. If not, please could you modify that test case to demonstrate your issue.

    Cheers,

    Colin

  • allenstyleallenstyle Posts: 4Questions: 1Answers: 0

    Hi Colin,

    Thank you for you reply!

    I saw your sample code, it worked very well.
    In fact, I want two fields not to fire edit mode while clicking on them.
    Could you give me tips for this?

    Thank you,

    Allen Tsai

  • kthorngrenkthorngren Posts: 20,322Questions: 26Answers: 4,774
    edited April 2019

    You would use the nth-child selector, for example:

    $('#example').on('click', 'tbody tr td:not(:first-child, :nth-child(6), :nth-child(7))', function() {
    

    Kevin

This discussion has been closed.