[jifty-devel] Save as... from inside a region
Stanislav Sinyagin
ssinyagin at yahoo.com
Tue Oct 26 16:20:17 EDT 2010
hi Thomas,
In the meanwhile, I solved the problem:
template '/' => sub
{
my $req_action =
Jifty->web->request->action('search');
if( defined($req_action) and
$req_action->argument('as_excel') )
{
show('/search_to_xls');
}
else
{
page {
h1 { 'The App' };
render_region(
name => 'search_devices',
path => '/fragments/search_devices',
);
}
}
};
template 'fragments/search_devices' => sub
{
..... skipped ....
if( $count > 0 )
{
form {
render_hidden( $search_action, 'ipaddr');
render_hidden( $search_action, 'macaddr');
render_hidden( $search_action, 'contains');
render_hidden( $search_action, 'as_excel', 1);
form_submit( action => $search_action,
label => 'Export to excel file',
as_link => 1,
as_button => 0,
region => '/' );
};
}
};
template '/search_to_xls' => sub
{
my $search_result = Jifty->web->response->result('search');
my $devices = $search_result->content('search');
$devices->order_by( {column => 'ipaddr', order => 'ASC'} );
Jifty->web->response->content_type("application/vnd.ms-excel");
my $xls;
my $fh = new IO::Scalar(\$xls);
my $workbook = Spreadsheet::WriteExcel->new($fh);
my $worksheet = $workbook->add_worksheet('IPACD_Search');
..... and so on ....
----- Original Message ----
> From: Thomas Sibley <trs at bestpractical.com>
> To: Nifty apps in a Jiffy <jifty-devel at lists.jifty.org>
> Sent: Tue, October 26, 2010 8:37:23 PM
> Subject: Re: [jifty-devel] Save as... from inside a region
>
> Hey Stan,
>
> On 26 Oct 2010 14:09, Stanislav Sinyagin wrote:
> > Is there an easy way to export the search results to some format from inside
>the
>
> > region?
> > Ideally it would be a link "Save results as excel".
> >
> > producing excel from a collection data is not a problem, but I'm a bit
> > stuck with dispatching from inside a region.
>
> I'm not sure exactly what you're trying to do inside the region, but the
> cleanest way is likely to pass the search arguments in a URL to another
> template that gets the collection and returns Excel data.
>
> Am I understanding the problem correctly?
>
> Thomas
> _______________________________________________
> jifty-devel mailing list
> jifty-devel at lists.jifty.org
> http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel
>
More information about the jifty-devel
mailing list