jQuery UI Widgets Forums Grid Extract grid data. output as array or variable ?

Tagged: , , ,

This topic contains 3 replies, has 2 voices, and was last updated by  ivailo 9 years, 1 month ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author

  • ashwin prabhu
    Participant

    Hi,

    I have extracted grid data with this code below:
    var data = \$("#jqxgrid").jqxGrid('exportdata', 'csv');

    If i did a console.log(data); to the above code, i get this as an output.

    "Order","Id","Comment"
    "6","12321","3rd test"

    is this data a variable and string ? it doesnot look like an array. 2nd thing- how can i convert this above data into an array.


    ashwin prabhu
    Participant

    i am able to convert it into an array with this simple code

    var array = data.split(",");
    console.log(array);

    Please ignore this post guys. Thanks


    ashwin prabhu
    Participant

    Pardon me, before you let this post go off.. i want one small help…

    "Order","Id","Comment"
    "6","12321","3rd test"

    There is a carriage return at the end of 2nd line. plus carriage returns for every row in my grid. How can i replace that carriage return with a comma ?

    i tried using regex but it didnt work. here is the code i tried using.

    data= data.replace(/\r/g,',');

    Instead of replacing carriage return (\r) with a comma (,) – it is giving me an error

    It says:
    Uncaught SyntaxError: Invalid regular expression: missing /


    ivailo
    Participant

    Hi ashwin prabhu,

    Try data= data.replace(/(?:\r\n|\r|\n)/g, ‘,’);
    Here is the demo.

    Best Regards,
    Ivailo Ivanov

    jQWidgets Team
    http://www.jqwidgets.com

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.