jueves, 8 de noviembre de 2012

Working With JQueryDataTable data

I´m using JQuery-DataTable in a SharePoint 2010 Application. 
I comunicate server to client throught $.getJSON(url, parameter, function(returnData){});
But when I pass the JSON to JQueryDatatable, it doesn´t work, why? I don´t Know.
It works, with arrays, not with objects, I don´t why. 
But we must convert the JSON Object into Array. So We have to use this simple function

function ConvertObjectToArray(obj) {
        var arr = [];

        for (cont = 0; cont < obj.length; cont++) {
            var t = 0;
            arr[cont] = [obj.length];

            for (var propiedad in obj[cont]) {
                arr[cont][t] = obj[cont][propiedad];
                t++;
            }
        }

        return arr;
    }

No hay comentarios:

Publicar un comentario