Adding Rows to a Grid in ExtJS 4.1

Note: Has been updated for ExtJS 4.1 In the last article we built a data grid mockup in ExtJS 4.1. Now we want to add some rows to the grid. Firstly we need to create a model class to store a data. We’ve done that also in the previously article, but for the better understanding, here’s it again: Ext.define('Person', { extend: 'Ext.data.Model', fields: ['firstName', 'lastName'] }); Having the Person class we can simply add new rows to the store (people in our case) by calling the add function with new instances of that class:...

February 27, 2009 · 1 min · admin

Building Mockups in ExtJS 4.1

Note: This post has been updated for ExtJS 4.1 In the early development phase it is usually a good idea to provide a mockup that is not using real data but some dummy data from memory. To do that for a grid in ExtJS we need to create a record class first. For a person this might look like this: Ext.define('Person', { extend: 'Ext.data.Model', fields: ['firstName', 'lastName'] }); Then we need a store where instances of the Person class will be stored:...

February 27, 2009 · 1 min · admin

Validator for ExtJS Checkbox

Very unfortunately ExtJS doesn’t offer a validator for its checkbox component. Normally a validator checks whether a field is valid and takes care of displaying an error message if not. For a checkbox we would like that to happen if the checkbox is not selected. Overriding the validate function of the checkbox we can provide such a functionality for all checkbox instances we are about to create: Ext.form.Checkbox.prototype.validate = function(){ if (this....

February 20, 2009 · 1 min · admin

Generic error handler for ExtJS

When you are doing client/server communication with ExtJS you probably run into the problem that you want to handle server side errors in a generic way. A solution that I found is to override the handleFailure function in the Ext.data.Connection class: Ext.data.Connection.prototype._handleFailure = Ext.data.Connection.prototype.handleFailure; Ext.data.Connection.prototype.handleFailure = function(response, e) { var errorText = Ext.DomQuery.selectValue("Reason/Text", response.responseXML, "Unknown Error"); Ext.Msg.alert('Error', errorText); Ext.data.Connection.prototype._handleFailure.call(this, response, e); }; This handler simply is called whenever a server side failure occurs....

February 9, 2009 · 1 min · admin

3 Ways to render HTML inside of a ExtJS container

It has been a while since my last blog post. The main reason is that I am now having a nice new job at efiport which leads to the situation that I am doing now good old Javascript (mainly ExtJS) instead of Flex. So I think in the future there will be more posts about ExtJS then Flex. Sorry Flex folks. To tribute the change a bit, I start with the problem of adding HTML code inside of a ExtJS container....

January 14, 2009 · 1 min · admin