-
Notifications
You must be signed in to change notification settings - Fork 0
paulhagstrom/jqGrid_widget
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
JQGrid widget A widget designed for Apotomo using jQuery and the jQGrid plugin (Now attempting to add support for datatables, will probably require a rename of the plugin later) The usage information is out of date. See the jqgrid_widget_demo for usage examples. Installation may someday be done with the Rails plugin architecture, but for now, it's all direct. I use submodules and symbolic links, and it goes like this: cd rails_app git submodule add git://github.com/apotonick/cells.git vendor/plugins/cells git submodule add git://github.com/apotonick/apotomo.git vendor/plugins/apotomo git submodule add git://github.com/paulhagstrom/jqGrid_widget.git vendor/plugins/jqgrid_widget get submodule init get submodule update cd public/images ln -s vendor/plugins/jqgrid_widget/public/images/indicator.white.gif ln -s vendor/plugins/jqgrid_widget/public/javascripts/jqgrid_widget.js ln -s vendor/plugins/jqgrid_widget/public/stylesheets/jqgrid_widget.css As can be deduced from above, this requires the following things: jqGrid_widget git://github.com/paulhagstrom/jqGrid_widget.git Added as a submodule, git will update apotomo git://github.com/apotonick/apotomo.git Added as a submodule, git will update cells git://github.com/apotonick/cells.git Added as a gem jQuery This can be downloaded from jquery.com. As I write this, it's at 1.4.2. Put updates in the public/javascripts folder. There is a symbolic link (jquery.js) to the current version, which needs to be redirected when there is an update. I have opted to point the symbolic link at the version that comes with jQuery UI, however. jQuery UI This also has to be downloaded, from jqueryui.com. As I write this, it's at 1.8rc3. I have made no attempt to minimize the components, maybe sometime I will take an inventory. I just downloaded the whole thing. Redmond theme. I don't know of a github repository. Installed into vendor/plugins, with symbolic links. There is a symbolic link (jquery-ui) to the current version, which needs to be redirected when there's an update. The theme setup seems less good than before, everything seems more integrated, harder to download just the theme files. For now, the symbolic link in public/stylesheets will force redmond. jqGrid git://github.com/tonytomov/jqGrid.git The git source is plugged in with a loader, which makes it easier to keep up to date, but for production, it is probably better to keep it up to date by hand by building it here http://www.trirand.com/blog/ As I write this, 3.6.4 is available, and I have built it as jquery.jqGrid.min.js. This does not point into the repository, and will not be updated by git updates, it needs to be fixed by hand. There is an alias jqGrid in vendor/plugins that points to the current jqGrid directory. This needs jRails too. TODO: Put this in. Usage: QUITE SERIOUSLY OUT OF DATE For the controller, inherit from JqgridWidgetController, set the layout, and have #index define the widget tree using #jqgrid_widget. Then render the widget (and its children) into an instance variable to send along to the view. class MainController < JqgridWidgetController layout 'applayout' def index use_widget a_parent_widget = jqgrid_top_widget('resource_name') embed_widget(a_parent_widget, a_child_widget = jq_grid_widget('sub_resource')) @a_parent_widget = render_widget(a_parent_widget.name) end end use_widget is defined by Apotomo, listy_widget is defined in JqgridWidgetController. For jqgrid_widget, the first and required argument is the "resource" (model name) from which the data is drawn. Other options include :cell_class (defaults to a class built from the resource name, e.g., ResourcesCell), :prefix (defaults to ''), :jqgrid_id (defaults to prefix + resources + '_list', e.g., 'resources_list'), :widget_id (defaults to prefix + resource, e.g., 'resource'), and :top_widget (defaults to 'no', but should be set to 'yes' for the top parent in a tree). The :top_widget parameter is used to bound message passing. And, better to use jqgrid_top_widget so that you need not share in the magical nature of :top_widget = 'yes'. The widgets themselves live in app/cells, where the cells are defined like ResourcesCell (resources_cell.rb), and the views for the cells are in a folder named resources (these conventions come from Apotomo/Cells). When defining the widget itself, the default behavior will do a lot, so most of what is inherited from JqgridWidgetCell can be left without changes. A simple example might be like this: def _setup super do |col| col.add_column('blurb', :width => 250) end @jqgrid_options.update({ :collapse_if_empty => true, :caption => 'Profiles', :height => 50 }) render end #add_column is defined by JqgridWidgetCell, and helps build the jqGrid. There are a bunch of options, I'll deal with them later. #scoped_model is just the resource model by default, but for children that depend on a parent selection, better to use parent.records.contacts. The list population will be built off of this scope with finds.
About
A plugin for Rails using Apotomo, Cells, and jqGrid
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published