# netzke-basepack A pack of basic Rails/ExtJS widgets, as a part of Netzke framework. # Prerequisites 1. Rails >= 2.2 2. ExtJS >= 2.0: its root *must* be accessible as RAILS_ROOT/public/extjs (you may symlink your ExtJS library here) # Installation gem install skozlov-netzke-basepack --source http://gems.github.com # Usage First, run the generators to have the necessary migrations (if not done so already): `./script/generate netzke_core` `./script/generate netzke_grid` Do the migrations: `rake db:migrate` This example will provide you with a grid-based scaffold for ActiveRecord-model called `Book`. If you don't have it already, you may generate it like this: `./script/generate model Book title:string amount:integer` (don't forget to do the migrations after this) In the controller declare the widget: `class WelcomeController < ApplicationController netzke_widget :books, :widget_class_name => 'Grid', :data_class_name => 'Book' end` After a widget is declared in the controller, it can be accessed in 3 different ways: 1) loaded by means of an automatically created controller action which will produce a basic HTML-page with the widget (handy for testing), 2) embedded directly into a view (by means of helpers), 3) dynamically loaded by other widgets (usually by the widget of class 'Application', if you want a desktop-like, AJAX-driven web-app). ## Using automatically created controller action Without writing any more code, you can access the widget by `http://yourhost/welcome/book_test`. That is to say, you append `_test` to your widget's name (as declared in the controller) to get the action name. ## Embedding a widget into a view Declaring a widget in the controller provides you with a couple of helpers that can be used in the view: 1. `books_class_definition` will contain the javascript code defining the code for the JS class. 2. `books_widget_instance` will declare a local javascript variable called `book`. Use these helpers inside of the `
the widget will be rendered in this div
` If your layout already calls `yield :javascripts` wrapped in the `