Maybe BUG

Maybe BUG

AntonQWERasdfAntonQWERasdf Posts: 5Questions: 1Answers: 0
edited February 2015 in Free community support

Hi! I'm trying to load an array of strings into the table, it turns out, but I see only the first character of each string per column. Maybe I missed some settings?

//my code
var dim_array = [];
for (var index = 0; index < distinct_values_for_filter.length; ++index) {
dim_array.push(distinct_values_for_filter[index].key);
};

$(tag_id).DataTable( {
    data: dim_array,
    columns: [
    {title: column_title}
    ],
    dom: 'T<"clear">lfrtip',
    rowSelect: 'multi',
    tableTools: {
        "sRowSelect": "os",
        "aButtons": [ "select_none", {"sExtends": "apply_filter", "csf_dimension": csf_dimension, "csf_group": csf_group}]
    }
    });

Everything works well if I fix one line in the function _fnGetObjectDataFn in jQuery.dataTble.js

/**
 * Return a function that can be used to get data from a source object, taking
 * into account the ability to use nested objects as a source
 *  @param {string|int|function} mSource The data source for the object
 *  @returns {function} Data get function
 *  @memberof DataTable#oApi
 */
function _fnGetObjectDataFn( mSource )
{...

    else
    {
        /* Array or flat object mapping */
        return function (data, type) { // row and meta also passed, but not used
            return data[mSource]; // error for cases, when data is string, always return first character.
            return data; // this my fix
        };
    }
}

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,934Questions: 1Answers: 10,155 Site admin

    Can you link us to a test case showing the issue please, or use the debugger to give us a trace.

    Allan

  • AntonQWERasdfAntonQWERasdf Posts: 5Questions: 1Answers: 0

    data from debugger okiyur

  • allanallan Posts: 61,934Questions: 1Answers: 10,155 Site admin

    Unfortunately the debugger says there were no tables on the page which probably means there was a Javascript error during the initialisation of the table. I would need a link to the page to be able to debug what is going on.

    Allan

  • AntonQWERasdfAntonQWERasdf Posts: 5Questions: 1Answers: 0

    Please, look at this debug obusar.
    I cant give you link, because it on my laptop localy.

  • allanallan Posts: 61,934Questions: 1Answers: 10,155 Site admin
    edited February 2015 Answer ✓

    "aaData": ["Фармаимпекс", "Фармстандарт", "Штада"... ]

    You only have a single string of data for each row. Did you mean to have that?

    aaData is normally an array of arrays or an array of objects. See data.

    Allan

  • AntonQWERasdfAntonQWERasdf Posts: 5Questions: 1Answers: 0

    Please, look at this example http://fiddle.jshell.net/hx7yygu5/3/

    I have array of strings, and i expect that i get table with one column. But I have something strange.

  • AntonQWERasdfAntonQWERasdf Posts: 5Questions: 1Answers: 0

    Thank you Allan! I figured with arrays. It was my mistake.

This discussion has been closed.