.setColumns(array);

139 views
Skip to first unread message

Marco Megna

unread,
Nov 14, 2012, 10:23:37 AM11/14/12
to google-visua...@googlegroups.com
Hi,
i've built this function that should redraw a table making me choose the fields.
When i click on a checkbox (.fieldsel), i take all the checked value in a form(#selectcampi) and put them in allVals array.

....
$('.fieldsel').click(function({
    var allVals new Array();

    $('#selectcampi :checked').each(function({
        allVals.push($(this).val());
    });

    var new google.visualization.DataView(data);
    v.setColumns(allVals);

    table.setView(v.toJSON());
    table.draw();
});

The problem is that v.setColumns()doesn't accept this array.
The error is:
Uncaught Error: Invalid column input, expected either a number or an object.

How could i pass to .setColumns() a list of columns properly?
Or maybe there is a way to pass it directly to .setView() without declare a .DataView?

Thanks!
Marco

Marco Megna

unread,
Nov 14, 2012, 10:32:31 AM11/14/12
to google-visua...@googlegroups.com
Solved... it was easy.
here's the solution, I hope that could be helpful for someone...

$('.fieldsel').click(function({
    var allVals new Array();
    $('#selectcampi :checked').each(function({
        allVals.push($(this).val());
    });
    var collist '{"columns":[' allVals.toString(']}';
    table.setView(collist);
    table.draw();
});

Bye,
Marco
Reply all
Reply to author
Forward
0 new messages