Victor
Victor

Reputation: 17087

how to import plugin class in ext js?

If I am developing an exts plugin class to be used in a grid. Let us say that the name of the plugin class is GridFilters.js and inside the plugin class, we have : Ext.namespace("Ext.ux.grid") In my SomeGrid.ui.js class, I am doing :

SomeGridUi = Ext.extend(Ext.grid.GridPanel, {
  title: '',
  frame: true,
  loadMask: true,
  cls: 'vline-on',
  flex :1,
  plugins : new Ext.ux.grid.GridFilters({filters:[
    {type: 'string',  dataIndex: 'someIndex'}
  ]}),

It says:

Message: 'Ext.ux.grid.GridFilters' is null or not an object

I understand, some kind of import needs to be done...but not sure exactly how.

Upvotes: 0

Views: 2112

Answers (2)

Rene Saarsoo
Rene Saarsoo

Reputation: 13917

Adding a <script> tag for the plugin into HTML - like Mchl sayd - is the simplest solution.

However, when you are developing anything a bit bigger I strongly recommend looking at some kind of dynamic loading solution:

RequireJS is probably the closest to a standard in this regard. Used by many-many projects out there.

For ExtJS specifically there is the already mentioned Ext.Loader, but that's probably way too simplistic to do anything serious. Most importantly it doesn't include a tool to build it all into one compact JavaScript file for deployment.

And then there is the promised ExtJS 4, that should come with all this built in. But one has to wait for it still...

Upvotes: 0

Mchl
Mchl

Reputation: 62369

Yeah, you need to add HTML to load GridFilters.js file before SomeGrid.ui.js.

And your plugin must be of course added to the namespace

Ext.ux.grid.GridFilters = ....

Upvotes: 3

Related Questions