Draw all the rows at a time from the dataset in dataview

Posted by: ralvee on 28 September 2017, 1:48 am EST

  • Posted 28 September 2017, 1:48 am EST

    I would like to print the spread view content just like it is drawn.

    dataView = new GC.Spread.Views.DataView(document.getElementById('grid1'), data, columns,
    new GC.Spread.Views.Plugins.GridLayout());

    I have noticed spread views does not draw all the elements from the dataset. When I scroll, it draws certain number of rows at a time. Can I customise the number of rows drawn? Or Can I get the all the rows drawn based on the given dataset? I need it to print the content of spread view using html canvas. Or is there any better way to print from the dataview?

  • Replied 29 September 2017, 11:46 am EST


    You can set the loadOnDemand feature to 'False' in order to not load rows as scrolled. For example:
    dataView.options.loadOnDemand = false;

    Deepak Sharma
  • Replied 2 October 2017, 10:46 pm EST

    Hi Deepak
    It does not work. I think you are referring this from live loading

    But I dont want live loading. I just want to specify the number of rows to be drawn when spread view (i.e. dataView) loads.
  • Marked as Answer

    Replied 3 October 2017, 12:29 am EST


    There is no such API for rendering entire content, if you want to print(render) all records at once, one option is to specify a big enough container. If that's not what you want and you just want to get all render info (HTML), here is a tricky way, hope that helps

    1. declare a hidden container

    <div style="display:none">
    <div id="grid1"></div>

    2. rewrite the built-in getContainerInfo_ method and return a right size to display all records. Views will measure the container size by calling window.getComputedStyle and it will return height = 0 if the container display is none, the other option is use a hidden (visibility: hidden) container with a right size and you don't need rewrite getContainerInfo_ method in that case.

    var dataView = new GC.Spread.Views.DataView(document.getElementById('grid1'), data, new GC.Spread.Views.Plugins.GridLayout());

    var handler = {
    apply: function(target, thisArgs, argumentList){
    return { contentRect: {top:0, left:0, height:2000,width:1000}};

    dataView.gCI_ = new Proxy(dataView.gCI_,handler );
    var viewportHtml = document.getElementById('grid1').outerHTML;

    Hope it helps.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels