Qztray HTML file printing issue, html print left side of the page - javascript

I am trying to print the HTML file using QZtray 2.0. File is printing on the left side of the page. I have set the height and width too, but same issue.
function printHTML()
{
var printData = [
{
type: 'html',
format: 'file',
data: test.html
}];
return qz.print(config, printData);
}
I have set the options,
`colorType: 'Color',
copies: 1,
density: 600,
duplex: '',
interpolation: '',
jobName: null,
legacy: '',
margins: 0,
orientation: 'Portrait',
paperThickness: '',
printerTray: '',
rasterize: true,
rotation: 0,
scaleContent: true,
size: null,
units: 'in'`

I have resolved the issue, by installing the beta version of qztraty 2.1, set the proper width and checked the printed document which looks proper.

Related

metronics mDatatable loading problem for huge data 40000 appx..Could not find any solution

metronics mDatatable does not load the table for huge data 40000 appx..so I dont know how to do server side with mdatatable as because mdatatable and datatable is different structure..Please help..
var datatable = $('.m_datatable_event_administrator').mDatatable({
// datasource definition
data: {
type: 'local',
source: resp,
pageSize: 10
},
// layout definition
layout: {
theme: 'default', // datatable theme
class: '', // custom wrapper class
scroll: false, // enable/disable datatable scroll both horizontal and vertical when needed.
// height: 450, // datatable's body's fixed height
footer: false // display/hide footer
},
// column sorting
sortable: true,
pagination: true,
search: {
input: $('#search_event_administrator')
},

jqGrid wrong data format?

Im trying to put some data into jqGrid and force it to be displayed in a treeview.
My problem is, the 6th item (cid=6) is not showing in the grid. The 4th item looks like it has some subitems, but expanding this branch shows nothing. The 6th item is nowhere to find in the tree (I suppose, I've defined it as subitem of cid4).
Here is a working example of this code http://jsfiddle.net/498jhxcg/
(my production code uses POST/AJAX/JSON, the example is changed to localdata. Grid is displayed in the same wrong way in both cases.)
Is the data in wrong format, or the jqgrid is wrong defined? (btw. changing parent_id to parentid did not helped.)
var myjsondata = '{"rows":[
{"cid":"1","name":"cat1","lvl":"0","parent_id":"null","isleaf":true,"expanded":false,"loaded":true},
{"cid":"2","name":"cat2","lvl":"0","parent_id":"null","isleaf":false,"expanded":false,"loaded":true},
{"cid":"3","name":"cat3","lvl":"1","parent_id":"2","isleaf":true,"expanded":false,"loaded":true},
{"cid":"7","name":"cat7","lvl":"1","parent_id":"2","isleaf":true,"expanded":false,"loaded":true},
{"cid":"4","name":"cat4","lvl":"0","parent_id":"null","isleaf":false,"expanded":false,"loaded":true},
{"cid":"6","name":"cat6","lvl":"1","parent_id":"4","isleaf":true,"expanded":false,"loaded":true},
{"cid":"5","name":"cat5","lvl":"0","parent_id":"null","isleaf":true,"expanded":false,"loaded":true}
],"records":7,"total":1}';
$('#jgtable').jqGrid({
ExpandColumn:'id',
datastr: myjsondata,
datatype: 'jsonstring',
colNames: [
'Id',
'Name',
'Parent id',
'isLeaf?',
],
colModel: [
{ index: 'cid', name: 'cid', width:"75px"},
{ index: 'name', name: 'name', width:"75px"},
{ index: 'parent_id', name: 'parent_id',width:"75px"},
{ index: 'isleaf', name: 'isleaf', width:"75px"},
],
pager: '#pager',
rowNum: 10,
rowList:[2, 10, 25, 50, ],
height: 'auto',
minHeight: '250px',
recordpos: 'right',
viewrecords: true,
gridview: false,
treeGrid: true,
treeGridModel : 'adjacency',
treedatatype: "local",
treeReader : {
level_field: "lvl",
parent_id_field: "parent_id",
leaf_field: "isleaf",
expanded_field: "expanded",
loaded_field: "loaded",
index_field: "cid",
},
jsonReader: {
repeatitems: false,
},
});
It seems to me that you should add key: true property to the definition of cid column. You can use alternatively (or to do both things) the option jsonReader: { id: "cid" }. In the case the value of cid property of input data will be interpreted as the id of the item and the value from parent_id will be correct.
see http://jsfiddle.net/OlegKi/498jhxcg/19/

jquery grid not filled with JSon data

Hi I am not able to get the data from JSON loaded on to grid,
HEre is my code for the grid wich displays the stock prices for the stock for a user :
$(document).ready(function () {
// $("#jQGrid").html("<table id=\"list\"></table><div id=\"page\"></div>");
jQuery("#jqTable").jqGrid({
url:jqDataUrl,
datatype: "json",
mtype: "POST",
height: 250,
// Specify the column names
colNames: ["SYMBOL", "LAST", "CHANGE", "%CHANGE","HIGH/LOW"],
// Configure the columns
colModel: [
{ name: "SYMBOL", index: "SYMBOL", width: 200, align: "left" },
{ name: "LAST", index: "LAST", width: 200, align: "left" },
{ name: "CHANGE", index: "CHANGE", width: 200, align: "left" },
{ name: "%CHANGE", index: "%CHANGE", width: 200, align: "left"},
{ name: "HIGH/LOW", index: "HIGH/LOW", width: 200, align: "left"}
],
jsonReader : {
root: "rows",
page: "page",
total: "total",
records: "records",
cell: "cell",
id: "id",
},
multiselect: false,
// paging: true,
// rowNum:10,
// rowList:[10,20,30],
pager: $("#jqTablePager"),
loadonce:true,
caption: "WatchList"
}).navGrid('#jqTablePager',{edit:false,add:true,del:true});
}
});
But when i try and run the code i am not able to get the contents on to the table (but the grid loads with no content)
And My json is of the form :
{
total: "1",
page: "1",
records: "2",
rows :
[
{id:"1", cell:["cell11", "cell12", "cell13","cell13","cell13"]},
{id:"2", cell:["cell21", "cell22", "cell23","cell13","cell13"]}
]
}
Please help me solve the problem
UPDATE:
I discovered that if you do not put repeatitems:true option into json reader, jqGrid assumes that you are using json dot notation. When you put it into jsonReader, your data is properly loaded. Here is working example: http://jsfiddle.net/a5e5F/3/
Old version:
I played a lot with your jqgrid code, and it seems that there is a bug in this version of jqGrid, which causes your jsonReader not to work. It reads data directly, ignoring root element and assuming that your data is array of json objects in format
{propertyName1:'PropertyValue1', propertyName2:'PropertyValue2', ...}
You can see what I mean on http://jsfiddle.net/a5e5F/2/
If you replace data:rows with data:data (your format of data), it does not load data. Maybe you should try to change your json data to use real json format (with properties named as columns)?
I have been trying a ton of stuff, changing column names to check for issue in #Barmar's coment, which I also thought it is the cause.

Getting height of ExtJS panel used as border region

I'm struggling mightily to get the height of an ExtJS panel and the only reason I can think it's any different is that it's the panel defined as a border region, because I've not had this problem otherwise (maybe I need to report a bug to them). I'll begin with some code that demonstrates how I'm trying to get the height, with results demonstrating what the height really is, what ExtJS says it is, and how it's not an issue with a panel using a different layout (one of the panels inside the border region):
'cmBuildTab #cmProductExplorer': {
afterrender: function(productExplorer) {
var domNode = Ext.getDom(productExplorer.el),
savedSearchesPanel = productExplorer.down('#savedSearchesPanel');
console.log('productExplorer.getHeight(): ' + productExplorer.getHeight());
console.log(productExplorer.componentLayout);
console.log(productExplorer.componentLayout.lastComponentSize);
console.log(domNode);
console.log('domNode.style.height: ' + domNode.style.height);
console.log('savedSearchesPanel.getHeight(): ' + savedSearchesPanel.getHeight());
}
},
I was initally encouraged I might have a couple of alternate ways to get the height, via the dom node, or via componentLayout.lastComponentSize but neither of these are accessible to Javascript code, only the chrome console. My final try then would be to parse the returned dom string but that is a horrible hack. Suggestions appreciated; below the console.log results is the pertinent portion of my view config.
console.log results:
productExplorer.getHeight(): 2
Ext.Class.newClass
autoSized: Object
borders: Object
calculateDockBoxes_running: false
childrenChanged: true
frameSize: Object
id: "dock-1155"
info: Object
initialized: true
initializedBorders: true
lastComponentSize: Object
height: 787
width: 254
__proto__: Object
layoutBusy: false
layoutCancelled: false
onLayout_running: false
owner: Ext.Class.newClass
previousComponentSize: undefined
targetInfo: Object
__proto__: Class.registerPreprocessor.prototype
undefined
<div id=​"panel-1049" class=​"x-panel x-box-item x-panel-default" role=​"presentation" aria-labelledby=​"component-1198" style=​"margin:​ 0px;​ width:​ 254px;​ height:​ 787px;​ left:​ 0px;​ top:​ 0px;​ ">​…​</div>​
domNode.style.height:
savedSearchesPanel.getHeight(): 151
View config (partial):
},{
region: 'west',
collapsible: true,
title: 'Product Explorer',
itemId: 'cmProductExplorer',
split: true,
width: '20%',
minWidth: 100,
layout: {
type: 'vbox',
pack : 'start',
},
items: [{
collapsible: true,
width: '100%',
border: false,
title: 'Search',
itemId: 'savedSearchesPanel',
items: [{
border: false,
xtype: 'cmSearchTermAccordionPanel'
},{
border: false,
margin: '5 20 0 20',
html: 'Saved Searches:<hr>'
}]
},{
afterrender is not the event you want to use to determine the heights of components, it fires when the elements have been rendered not after they have been sized. If you are using 4.1 you can use the boxready event which fires only once the the container is intially sized http://docs.sencha.com/ext-js/4-1/#!/api/Ext.AbstractComponent-event-boxready . If not you can use the afterlayout event to determine size but that event fires every layout.
Also fyi widths as percentages are not documented as supported in 4.0, I've seen them work and I've seen them fail.
Here is some code I hijacked from the Viewport example thanks to a court ruling this is ok.
4.1
Ext.create('Ext.container.Viewport', {
layout: 'border',
items: [{
region: 'north',
html: '<h1 class="x-panel-header">Page Title</h1>',
border: false,
margins: '0 0 5 0'
}, {
region: 'west',
collapsible: true,
title: 'Navigation',
width: 150,
//ADD LISTENERS
listeners: {
afterrender:function(){console.log( 'afterrender ' +this.getHeight())},
boxready:function(){console.log( 'boxready ' +this.getHeight())}
}
// could use a TreePanel or AccordionLayout for navigational items
}, {
region: 'south',
title: 'South Panel',
collapsible: true,
html: 'Information goes here',
split: true,
height: 100,
minHeight: 100
}, {
region: 'east',
title: 'East Panel',
collapsible: true,
split: true,
width: 150
}, {
region: 'center',
xtype: 'tabpanel', // TabPanel itself has no title
activeTab: 0, // First tab active by default
items: {
title: 'Default Tab',
html: 'The first tab\'s content. Others may be added dynamically'
}
}]
});
Output :
afterrender 2
boxready 276

JqGrid pager problem - Total pages and records does not display correctly

Issue: My jqGrid pager shows Page 1 of NaN instead of the correct number of pages.
Fiddler shows that I am getting the correct json from my WCF call:
{"total":1,"page":1,"records":2,"rows":[{JDEVendorNumber":99999999,
"VendorName":"Super Vendor","BillID":"99999999wwerer ",
"CommunityName":"Post Abbey ",
"PrimaryAcctNumber":"wwerer","CommunityID":"600402","RecordID":8}]}
My grid setup is as follows:
$invoiceGrid.jqGrid({
datatype: 'json',
mtype: 'GET',
url: url,
colNames: ['Vendor Name', 'CommunityName', 'Primary Acct Nbr', 'BillID'],
colModel: [
{ name: 'VendorName', index: 'VendorName', width: 203, align: 'left' },
{ name: 'CommunityName', index: 'CommunityName', width: 215, align: 'left' },
{ name: 'PrimaryAcctNumber', index: 'PrimaryAcctNumber', width: 260, align: 'left' },
{ name: 'BillID', index: 'BillID', hidden: true }
],
rowNum: 50,
gridview: true,
rowList: [10, 20, 30, 50],
pager: $('#invoicepager'),
sortname: 'PrimaryAcctNumber',
viewrecords: true,
sortorder: "asc",
rownumbers: false,
hidegrid: false,
repeatitems: false,
recordtext: 'Bill(s) {0} - {1} ',
cell: "",
height: "auto",
loadComplete: function(data) {
//alert('total is ' + data.responseText);
if ($invoiceGrid.jqGrid('getGridParam', 'records') == 0) {
NoRecordsFound();
} else {
SetSearchResultsInterface('bills');
}
EnableControl($search, true);
Global.grdInitialized = true;
$progressbar.hide();
},
jsonReader: {
repeatitems: false,
id: "RecordID"
}
}).navGrid('#invoicepager', { edit: false, add: false, del: false, search: false, refresh: false });
My data is displayed correctly but the pager shows NaN for total pages and total records. Any ideas? Thank you for your help
It seems that correct format of recordtext should has 3 elements like
recordtext: "View {0} - {1} of {2}"
You use
recordtext: 'Bill(s) {0} - {1} '
You can use
recordtext: 'Bill(s) {0} - {1} of {2}'
instead. But I can not really reproduce your problem also in case of the usage of your original data (see http://www.ok-soft-gmbh.com/jqGrid/PagerProblem.htm which has no problems).
Moreover your JSON data should be fixed:
[{JDEVendorNumber"
should be fixed to
[{"JDEVendorNumber"
but probably it's come during posting the data only.
Oleg, by looking at the sample code you sent me, I figured that for the pager to work correctly you need to include grid.formedit.js. In my page I had references only to grid.locale-en.js and jquery.jqGrid.min.js. Apparently that is not enough. I guess, lesson learned for me is to include all the .js libraries that are part of the jqGrid download. Thanks for your help
Although it does not seem to be the problem here, the loadonce parameter may cause a similar issue (total pages always set to 1). It should be forced to false:
$myGrid.jqGrid({
datatype: 'json',
loadonce: false,
...
}
The loadonce parameter prevents the client from loading further data after the initial load. As a side effect, the client ignores total and records in the server's response, using only the amount of rows to populate the pager.
In my own code, loadonce must have been defaulted to true, because the pager worked as soon as I explicitly set it to false.

Categories