PDA

View Full Version : Passing Data to a new Window in order to Print the new Window only



wmearns
26 Jun 2013, 11:07 AM
Hello,

So I'm creating like a print window functionality. A button opens up a new window from .html file. This file just has a script that creates everything from a template of another html.

There are a few things I'm trying to do to mess with the template but I'm not sure if there's a rendering issue or what.

So the button opens new window with following code


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="description" content="">
<title>Thoroughbred Direct - Proof of Service</title>
<script type="text/javascript" charset="utf-8" src="../../../resources/ext-4.2.0.663/ext-dev.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<style type="text/css">
//css ommitted
</style>
</head>
<body>
<script type="text/javascript">
Ext.require('Ext.Ajax');
Ext.require('Ext.container.Container');
Ext.onReady( function() {
var msg = 'index-1';
jQuery('format.html #img').attr('src', '/url/' + msg);

var clone = jQuery('format.html #td1').clone();
jQuery('format.html #tr1').append(clone);

var loadArr =[{
stuff: 'yo',
foo: 'bar'
}];

// Create a utility class
Ext.define('myapp.util.Util', {
singleton: true,

loaderXTemplateRenderer: function(loader, response, active) {
var tpl = new Ext.XTemplate(response.responseText);
var targetComponent = loader.getTarget();
targetComponent.update( tpl.apply(targetComponent.data) );
return true;
}
});

Ext.create('Ext.container.Container', {
renderTo:Ext.getBody(),
data: { load: loadArr },
loader: {
url:'format.html',
autoLoad: true,
renderer: myapp.util.Util.loaderXTemplateRenderer
}
});
});
</script>
</body>
</html>


this uses the template of this code



<tpl for="load">
<table>
<tr id="tr1">
<td id="td1">
<table><tr><td>Items Owned: </td>
<td>{stuff}</td></tr>
<tr><td>More things: </td>
<td>{foo}</td></tr>
<tr><td>
<img id="img" alt="hi" src="" /> </td></tr></table>
</td>
</tr>
</table
</tpl>


My issues are that the first td (td1) doesnt duplicate like it's supposed to nor is my image getting its src correctly pushed. I don't know if it's a problem with rendering and code being ran at wrong times or not. It looks like the values should be set in the template before template gets rendered? I could use a second set of eyes.

Thanks

wmearns
26 Jun 2013, 12:59 PM
Hello,
I have a grid of data. What I want to do is, via a button click (while having a row selected), pass data and create a new window. This new window will have XTemplate information that will be able to plug in this data into some pretty generic HTML. The html will just be a table with duplicated information on both halves of the page (see below table). This new window will then be easily printed by the browsers print functionality.

I thought I had this figured out in my previous post (http://www.sencha.com/forum/showthread.php?266505-HTML-XTemplate-Window-from-Button): http://www.sencha.com/forum/showthread.php?266505-HTML-XTemplate-Window-from-Button
but I was mistaken. I couldn't find a way to unanswer the post so here is hopefully a better worded one...

Can someone help me out?



Table
<td>


Table

<td>


<tr>
stuff

<tr>
stuff

slemmon
28 Jun 2013, 1:26 PM
Would you be able to post a more inclusive test case including what your data looks like when you apply it to the template?