6

I'm using datatables with processing message but I would like to block datatable when this message show up. This is important because otherwise the user may use an old row. This is my configuration:

datatableTable = $('#datatableTable').DataTable({
            responsive: true,
            "bLengthChange": false,
            deferRender:    true,
            scrollY:        '60vh',
            scrollCollapse: true,
            scroller:       true,
            "bProcessing": true,

and I'm using this message css:

div.dataTables_wrapper div.dataTables_processing {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 200px;
  margin-left: -100px;
  margin-top: -26px;
  text-align: center;
  padding: 1em 0;
  z-index: 9999;
}

Is there a way to block datatable? thanks

7
  • What do you exactly mean by "block datatable"? Disabling datatable control elements such as pagination and column headers or something else? Commented Dec 6, 2016 at 13:41
  • In each row of my datatable I have several buttons, files browse and so forth, I would like to forbid the use of these element. Commented Dec 6, 2016 at 13:45
  • Then it has no relation to datatables. Since you output your input elements inside table yourself, you have to disable them yourself too. Datatables can't do all work for you. Commented Dec 6, 2016 at 13:50
  • Isn't it possible to disable the entire datatable? I see that all the commands given during processing are elaborated at the end of elaboration (even the columns ordering) Commented Dec 6, 2016 at 13:53
  • No way except manual disabling all child input elements (e.g. using loops). Commented Dec 6, 2016 at 13:58

1 Answer 1

1

You can just disable mouse interaction:

$("body").addClass("disabled");

And css:

.disabled {
    pointer-events: none;
}

You can also put a fixed overlay between your message and body and set some opacity (like 0.5), black background, proper z-index etc. to make it hide everything that is behind.

Maybe you should also read something about database's transactions - there're a solution for many problems with data.

Sign up to request clarification or add additional context in comments.

4 Comments

I already have my modal to disable all page, I was only wondering if was possibile to disable only the table
Of course - you can add id for your table (for example #tableid) and write:
$("#tableid").addClass("disabled"); :)
I have the same issue, Is there any way to freeze the pagination button when the datatable is processing?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.