Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
3790
get the grid table in one array
posted

I need to get all the data in to an array that is shown on the screen. The data provider is no good because its out of order and/or changed. I need basically a snapshot of my data rows and columns included either in the same shot or other calls.

1234
1234
1234

so something like:
getHeaderRow should give me [1,2,3,4]
getHeaderColumn should give me [1,1,1]
getData should give me [2,3,4],[2,3,4]

or just one big array [1,2,3,4],[1,2,3,4],[1,2,3,4]

any thoughts?

Parents
No Data
Reply
  • 15320
    Verified Answer
    Offline posted

    Hello seang,

    Thank you for posting in our community.

    It's been a while since your last request, but if you still need assistance I'll be glad to help you.

    Regarding your question about getting the grid data and displaying it in an array on the page, I would suggest you to use rowsRendered event and get reference to the grid datasource by

    ui.owner.dataSource.data(), then iterate through this data, which is represented as array of objects, access the respective grid data fields by their data keys and save them to an array. As result this array might be displayed in a simple div element on the page. Here is a code snippet for your reference:

    rowsRendered: function(evt, ui) {

                var grid = ui.owner;    

                var data = grid.dataSource.data();

                var output = document.getElementById("dataOutput");

                var dataArray = new Array();   

                for (var i = 0; i < data.length; i++) {

                    dataArray.push("[" + data[i].ProductID, data[i].Name, data[i].ProductNumber + "]<br/>");

                }

                output.innerHTML += dataArray.toString();

            },

     Please let me know if I didn't understand your question properly.

    Attached is also a sample with similar scenario for your reference.

    If you have any further questions, feel free to contact me.

     

    Sincerely,

    Tsanna

    DisplayGridDataIntoArray.zip
Children