Things in quote, and function parameters

Things in quote, and function parameters

ngungongungo Posts: 64Questions: 23Answers: 2

Hi,

Few obvious things but I don't have answers for it. Please bear with me. Thanks.
1. Sometimes "thing" in quote, and then sometimes not. Why? For example:

    columns: [
        {
            "className":      'details-control',
            "orderable":      false,
            "data":           null,
            "defaultContent": ''
        },
        {"data": "combo"},
        {"data": "x"},
        {
            data:   "urgent",
            render: function (data, type, row) {
                if (type === 'display') {
                    return '<input type="checkbox" class="editor-urgent">';
                }
                return data;
            },
            className: "dt-body-center"
        },
  1. Function parameters. What is available or what is the rule?
    targets: 1, render: function(row, type, val, meta) {
        ...
    render: function (data, type, row) {    

This question has accepted answers - jump to:

Answers

  • tangerinetangerine Posts: 3,143Questions: 27Answers: 366
    Answer ✓

    Your questions are not specific to DataTables. They have to do with scripting styles and preferences.
    For instance, use quotes or don't use them. It's your choice.
    I suggest you read up on best practices in JS and jQuery scripting.

  • allanallan Posts: 54,882Questions: 1Answers: 8,601 Site admin
    Answer ✓

    Absolutely - its just a code style thing. In JSON you absolutely require the double quotes for the parameter key, but in Javascript it is option (in most cases!). I used to use double quotes everywhere, but now prefer to not use them if they aren't needed. Which is why there is a little bit of a mix of styles on this site.

    I'd suggest picking one and sticking with it.

    Function parameters. What is available or what is the rule?

    Whatever the documentation says. In Javascript if you don't use a parameter you can simply not include it. Very few people use the meta parameter, which is why you don't see it often. Again a coding style.

    Allan

  • ngungongungo Posts: 64Questions: 23Answers: 2

    Thank you. Both of you. I appreciate your help, as always.

  • ngungongungo Posts: 64Questions: 23Answers: 2

    Hi,

    I have read the documentation many times but still not really comprehend, or specifically where to look at. Obviously I can see there are parameters such as: row, data, type, val, meta, but not xxx, yyy, zzz nor abc. I am wondering if there is an exhaustive list of parameters, or there is way (to look for) to know if abc is a legitimate parameter, or whatelse available.

    I know you don't have much time. Of course, you are not obligated to answer my question since it is too silly. :) Thanks.

  • allanallan Posts: 54,882Questions: 1Answers: 8,601 Site admin

    I am wondering if there is an exhaustive list of parameters

    Yes. Likewise for the API, Buttons, etc - see the reference section.

    Allan

This discussion has been closed.