Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Transform Sequel Dataset to ExtJS JsonStore feed

tree: 785fdf92ee

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 .gitignore
Octocat-spinner-32 CHANGELOG.rdoc
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 sequel_extjs.gemspec
README.rdoc

is :ExtJS

Add a to_extjs function to any Sequel Dataset, it will generate json that is consumable by the ExtJS JsonStore.

Take a look at Sequel::Plugins::ExtJS::DatasetMethods.to_extjs function for more information.

Usage

# this will require the Sequel's ExtJS plugin
require 'sequel_extjs'
# this will add .to_extjs on the Array class, so you can use the same code for datasets and array results
# not required, if you don't like additions to the Array class
require 'array_extjs'

class MyModel < Sequel::Model(:mymodel) 
   is :ExtJS
 end

# now output all MyModel records in a way the JsonStore expects:
MyModel.to_extjs
# or use any filters before that
MyModel.filter(:status => true).to_exts
# or limit it for pagination
cnt = MyModel.filter(:status => true).count
MyModel.filter(:status => true).limit(10,100).to_extjs(cnt)
# also give it a block and it will more or less work like a 'map'
MyModel.filter(:status => true).to_exts do |rec|
  rec[:newprop] = "Status is #{rec.status}"
  rec
end
Something went wrong with that request. Please try again.