CatalystX::CRUD::YUI::LiveGrid(3)

NAME
CatalystX::CRUD::YUI::LiveGrid - ExtJS LiveGrid objects

SYNOPSIS
 my $livegrid = $yui->livegrid(
            results     => $results,    # CX::CRUD::Results or CX::CRUD::Object
            controller  => $controller,
            form        => $form,
            method_name => $rel_info->{method},
            col_names   => $form->metadata->field_methods,
            c           => $c,          # Catalyst context object
 );

 $livegrid->serialize;  # returns serialized results
 $livegrid->count;      # returns number of rows

DESCRIPTION
This class represents the data necessary to support the ExtJS-base LiveGrid component http://www.siteartwork.de/livegrid/.

METHODS

  new( opts )
Create a YUI LiveGrid object. You usually call this via CatalystX::CRUD::YUI->livegrid( opts ).

opts should include:

results
    The results object passed in. May be either a CatalystX::CRUD::Results instance or CatalystX::CRUD::Object instance.

    If a Results instance, each object in the Results set will be serialized.

    If a Object instance, each object returned by method_name will be serialized.

form
    The form object should be an instance of the Form class that corresponds to the data being serialized. In the case where results isa CatalystX::CRUD::Results object, form should be a Form corresponding to the object class in CatalystX::CRUD::Results->results(). In the case where results isa CatalystX::CRUD::Object, form should be a Form corresponding to the foreign object class represented by method_name.

controller
    The controller object should be the governing controller for the objects being serialized, i.e., the controller governing form.

The new LiveGrid has the following accessors available:

pk  The primary key of the table that results represents.

columns
    An arrayref of column hashrefs. YUI LiveGrid API requires these.

url The url for fetching JSON results.

show_related_values
    A hashref of foreign key information.

col_filter
    An arrayref of column names. Used for filtering table by specific column values.

col_names
    An arrayref of column names. Defaults to form->metadata->field_methods.

data
    An arrayref of hashrefs. These are serialized from results.

count
    The number of items in data.

counter
    User-level accessor. You can get/set this to whatever you want.

NOTE: If you pass a CatalystX::CRUD::Object instance as results to new(), the object must implement a primary_key_uri_escaped() method that conforms to the syntax defined by CatalystX::CRUD::Controller make_primary_key_string(). See Rose::DBx::Object::MoreHelpers for one example.

  column( field_name )
Return the column hashref meta for field_name. The hashref has 3 keys: key, label, and sortable.

  serialize
Returns LiveGrid as array ref of hash refs, suitable for conversion to JSON or other transport type.

  json_reader_opts
Returns hash ref suitable for JSON-ifying and passing to the LiveGrid JsonReader constructor.

  json_reader_columns
Returns array ref suitable for JSON-ifying and passing to the LiveGrid JsonReader constructor.

  column_defs
Returns array ref suitable for JSON-ifying for LiveGrid JS.

AUTHOR
Peter Karman, "<karman@cpan.org>"

BUGS
Please report any bugs or feature requests to "bug-catalystx-crud-yui@rt.cpan.org", or through the web interface at <http://rt.cpan.org>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

ACKNOWLEDGEMENTS
The Minnesota Supercomputing Institute "http://www.msi.umn.edu/" and NALD "http://www.nald.ca/" sponsored the development of this software.

COPYRIGHT & LICENSE
Copyright 2008 by the Regents of the University of Minnesota.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.