Using jQuery To Present/Format Data

Using jQuery To Present/Format Data

Hi guys,

I have a web application that reads data from a CSV .txt file. Example of data:

OrderNum, Importance, Date, Summary, WithinTime
11111, 1, 01-09-2012, blah blah blah, OutOfTime
22222, 3, 14-08-2012, xxx xxx xxx, InTime
33333, 2, 27-09-2012, yyyy yyyy yyyy, Other
44444, 1, 03-10-2012, abc abc abc, OutOfTime
55555, 4, 01-10-2012, zzz zzz zzzz zzzzz, NearTime

Currently, when a particular WithinTime button is selected, for example OutOfTime, my code searches through all the records that have OutOfTime in a row and return the output in a single lined div.

I want to change the way this div displays the data from:

11111, 1, 01-09-2012, blah blah blah, OutOfTime

To:

11111 - 01-09-2012 1
blah blah blah

Current code:

  1.     $('#OutOfTime').click(function () {
            var html = '';
            $.each(searchData(allData, 'Near SLA'), function (i, line) {
                html += line.join(',') + '<br>';
            });
            $('#output').html(html);
        });





  2. function processData(allText) {
        var allTextLines = allText.split(/\r\n|\n/);
        var headers = allTextLines[0].split(',');
        var lines = [];
        for (var i = 1; i < allTextLines.length; i++)
        {
            var data = allTextLines[i].split(',');
            if (data.length == headers.length)
            {
                lines.push($.map(data, function (field, j)
                {               
                    //return headers[j] + ':' + field;
                    return field;
                }));
            }
        }
        // Returns the data you need, to be stored in our variable
        return lines;
    }

    function searchData(data, search)
    {
        return $.grep(data, function (line, i)
        {
            return line.join('|').match(search);
        });
    }



























Any help is appreciated.