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

26 Jun 2013, 11:07 AM

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>
<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-"></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
<script type="text/javascript">
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', {
data: { load: loadArr },
loader: {
autoLoad: true,
renderer: myapp.util.Util.loaderXTemplateRenderer

this uses the template of this code

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

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.


26 Jun 2013, 12:59 PM
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?






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?