Warning dialog annoyance

Warning dialog annoyance

sd_zuosd_zuo Posts: 78Questions: 1Answers: 0
edited July 2010 in General
I met with the following situation quite a few times and felt a little inconvenient about the behavior.

I put an empty TABLE element on the page and then fill it with a JSON recordset.
During the development process, it happened that the DataTables column configuration did not match the number of columns from the JSON records. A warning dialog about that kept popping up. The JSON had quite hundreds of records. I could not do anything to stop the warning message boxes from showing up except terminating the process of iexplore.exe.

Is it possible to change the warning to show up just once during the initialization?

Replies

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    At the moment the way to do this is to put DataTables' error handling into exception mode ( $.fn.dataTableExt.sErrMode = "throw" - something which is new in 1.7 beta 6), which will just cause a ton of JS errors rather than alerts.

    However, it probably is reasonable to have this alert occur only once, rather than for every row which is in error. I'll look at making that modification.

    Regards,
    Allan
  • samsam Posts: 1Questions: 0Answers: 0
    Hi Allan,

    Would you consider removing "alert" as the default exception mode? I was a little surprised when I saw them come up on a production site, and had to step thru it to find the sErrMode property.

    It would also be convenient if you could set sErrMode directly in the options object passed to dataTables() — I was loading the dataTables script dynamically and didn't have a good way to set $.fn.dataTableExt.sErrMode beforehand.

    Thanks for the plugin! S
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    I certainly have considered it, but the reason I've kept it as 'alert' for now is to make it unavoidably clear to the developer that there is a problem somewhere which needs to be addressed. I am certainly willing to consider changing this default, but it is surprising the number of posts in the forum where a simple JS error hasn't been caught (from looking at the Firebug console or whatever).

    Allan
  • totallyplandomtotallyplandom Posts: 27Questions: 1Answers: 1
    I'm sorry, but I'm adding $.fn.dataTableExt.sErrMode = 'throw' to my code and it's not suppressing the error. How *exactly* should this be used?

    Best.
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    [code]
    $.fn.dataTableExt.sErrMode = 'throw';
    $('#example').dataTable();
    [/code]

    should do it. If it doesn't can you link us to your test page please.

    Allan
  • totallyplandomtotallyplandom Posts: 27Questions: 1Answers: 1
    edited February 2012
    Unfortunately (due to security reasons) I can't link the page. Should I insert it on "document ready", before the tables are initialized, or afterward? That code doesn't work for me, but if I change the default in the "datatables.js.min" file, it works.
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    Here is an example of how it might be done: http://live.datatables.net/ocequq/edit

    Allan
  • drakula1234drakula1234 Posts: 58Questions: 1Answers: 0
    Even for me it is not suppressing that error related to JSON. Do I need to handle that error or is it done automatically ?
  • drakula1234drakula1234 Posts: 58Questions: 1Answers: 0
    edited March 2012
    Allan,

    I keep getting this error message [quote]DataTables warning: JSON data from server could not be parsed. This is caused by a JSON formatting error[/quote] even though it is not a JSON parse exception. I wanted to test the functionality, wantedly I am not sending any data to the datatable to see if the statement [quote]$.fn.dataTableExt.sErrMode = 'throw'[/quote]will suppress the warning message. It is not suppressing the message for me, I am not sure how to handle this.
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    It should now suppress the alert (changing it into a throw) in 1.9.1.dev (grab the nightly from http://datatables.net/download ).

    Allan
  • drakula1234drakula1234 Posts: 58Questions: 1Answers: 0
    edited March 2012
    I am working on a dev environment currently, I am not sure if I can use a dev version unless it is a stable release. I have the latest 1.9.0 though. What I have done is set the sEcho, aaData and etc to 0 to suppress that warning..
  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    Fair enough. 1.9.1 should be available soon.

    Allan
This discussion has been closed.