Dataview print preview

Hi,
Is there a way to use printView() from grid for Dataview object?

Hi,

printView() can be used only for Grid. Unfortunately, there is not a ready solution for Dataview.

I came up with the solution that you can put in dhtmlxdataview inside the prototype definition dhtmlXDataView.prototype={…
printView:function(b,d){
var html=“TD { font-family:Arial; text-align:left; padding-left:2px;padding-right:2px; } \n td.filter input, td.filter select { display:none; } \n </style>”;
html += ‘

’;
var max_ind = this.data.max;
var min_ind = max_ind - this._settings.pager._settings.size;
var dataObj = this.data;
this.data.each(function(obj){
//Find out the property name
var propnames = “”;
for (var name in obj) {
if ( name != “id” && name != “value” ) {
propnames += eval(“obj.”+name) + " ";
}
}
            if ( dataObj.indexById(obj.id)  > min_ind  && dataObj.indexById(obj.id) <= max_ind  ) {
                html += '<tr>';
                html += '<td style="color:black;align:left">' + propnames +'<\/td>';
                html += '<\/tr>';
            }
        });
        html += '<\/table>';
        var d = window.open('', '_blank','toolbar=yes,scrollbar=yes,resizable=true');
        d.document.write(html);
        d.document.write("<script>document.body.scroll = 'auto';window.onerror=function(){return true;}<\/script>");
        d.document.close();
    }

Hello,

Thank you for the provided solution. It will be helpful for others who have faced the same issue. However, this method can not be applied to any dataview:

  • it can be used only for dataview with pager,
  • the method doesn’t consider dataview template.