<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Superdit.com &#187; Extjs</title>
	<atom:link href="http://superdit.com/tag/extjs/feed/" rel="self" type="application/rss+xml" />
	<link>http://superdit.com</link>
	<description>blogging, design, tech, and web</description>
	<lastBuildDate>Fri, 30 Jul 2010 13:27:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Extjs : Form Submit With Enter Key Event</title>
		<link>http://superdit.com/2010/06/04/extjs-form-submit-with-enter-key-event/</link>
		<comments>http://superdit.com/2010/06/04/extjs-form-submit-with-enter-key-event/#comments</comments>
		<pubDate>Fri, 04 Jun 2010 13:44:08 +0000</pubDate>
		<dc:creator>aditia rahman</dc:creator>
				<category><![CDATA[Extjs]]></category>
		<category><![CDATA[form]]></category>

		<guid isPermaLink="false">http://superdit.com/?p=781</guid>
		<description><![CDATA[This is the short post that I want to share, cause last year I had created form in Extjs and submitted using ENTER key event so I want to share that here the simple code in Extjs form to enabling ENTER key event, but using this code your mouse cursor should be focused on one [...]]]></description>
			<content:encoded><![CDATA[<p>This is the short post that I want to share, cause last year I had created form in Extjs and submitted using ENTER key event so I want to share that here the simple code in Extjs form to enabling ENTER key event, but using this code your mouse cursor should be focused on one of the field inside the form, this is very simple so I don&#8217;t think I need to provide the downloadable source code, here it goes:</p>
<pre class="brush: jscript;">
Ext.onReady(function(){
    var formLogin = new Ext.FormPanel({
        frame: false, border: false, buttonAlign: 'center',
        url: BASE_URL + 'user/extjs_login', method: 'POST',
        id: 'frmLogin',
        items: [{
            xtype: 'textfield',
            fieldLabel: 'Username',
            id:'fldusername',
            name: 'username',
            allowBlank: false
        }, {
            xtype: 'textfield',
            fieldLabel: 'Password',
            id:'fldpassword',
            name: 'password',
            allowBlank: false,
            inputType: 'password'
        }],
        buttons: [
            { text: 'Login' },
            { text: 'Reset', handler: function() {
                    formLogin.getForm().reset();
                }
            }
        ],
        keys: [
            { key: [Ext.EventObject.ENTER], handler: function() {
                    Ext.Msg.alert(&quot;Alert&quot;,&quot;Enter Key Event !&quot;);
                }
            }
        ]
    });

    var winLogin = new Ext.Window({
        title: 'Extjs Enter Key Event', layout: 'fit',
        width: 340, height: 140, resizable: false,
        closable: false, items: [formLogin]
    });

    winLogin.show();
});
</pre>
<p><span id="more-781"></span></pre>
<p>As you can see on the code above just add the config <em>"keys" </em>property and use the event key <em>"Ext.EventObject.ENTER", </em>that's all.</p>
]]></content:encoded>
			<wfw:commentRss>http://superdit.com/2010/06/04/extjs-form-submit-with-enter-key-event/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Creating Register and Login Form Using EXTJS and CodeIgniter</title>
		<link>http://superdit.com/2010/06/02/creating-register-and-login-form-using-extjs-and-codeigniter/</link>
		<comments>http://superdit.com/2010/06/02/creating-register-and-login-form-using-extjs-and-codeigniter/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 06:07:41 +0000</pubDate>
		<dc:creator>aditia rahman</dc:creator>
				<category><![CDATA[Codeigniter]]></category>
		<category><![CDATA[Extjs]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[form]]></category>

		<guid isPermaLink="false">http://superdit.com/?p=460</guid>
		<description><![CDATA[Like another tutorial this post will create the basic form login and register using Extjs and Codeigniter, and I want to mix my previous post about Codeigniter Session Library, Extjs Unique Field Validation and using Statusbar in Extjs Window. 1. Setting up the database Using phpmyadmin in XAMPP I create the database named &#8220;ci_extjs_login&#8221;, and create [...]]]></description>
			<content:encoded><![CDATA[<p>Like another tutorial this post will create the basic form login and register using Extjs and Codeigniter, and I want to mix my previous post about <a href="http://superdit.com/2010/04/17/creating-user-session-checking-with-codeigniter-library/" target="_blank">Codeigniter Session Library</a>, <a href="http://superdit.com/2010/05/07/unique-field-form-validation-using-php-and-extjs/" target="_blank">Extjs Unique Field Validation</a> and <a href="http://superdit.com/2010/05/24/extjs-window-form-masking-with-statusbar/" target="_blank">using Statusbar in Extjs Window</a>.</p>
<p><strong>1. Setting up the database</strong></p>
<p>Using phpmyadmin in XAMPP I create the database named &#8220;ci_extjs_login&#8221;, and create simple &#8220;users&#8221; table, here below is the sql code that I generated from phpmyadmin, for more advance database modelling you can use <a title="mysql workbench" href="http://wb.mysql.com/" target="_blank">mysql workbench</a>.</p>
<pre class="brush: sql;">
CREATE TABLE  `ci_extjs_login`.`users` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`username` VARCHAR( 100 ) NOT NULL ,
`password` VARCHAR( 100 ) NOT NULL ,
`email` VARCHAR( 100 ) NOT NULL
) ENGINE = MYISAM ;</pre>
<p><span id="more-460"></span></p>
<p><strong>2. Setting up the Codeigniter</strong></p>
<p>If you not have the copy of codeigniter you can download the latest from its official site <a title="codeigniter" href="http://codeigniter.com" target="_blank">here</a>, then copy the extracted file in your server folder, (here I&#8217;m using the default XAMPP htdocs), first setting the databse connection, open the file <em>&#8220;system/application/config/database.php&#8221;</em>, set the hostname, username, password, and database name (for username &amp; password I&#8217;m using the XAMPP default)</p>
<pre class="brush: php;">
$db['default']['hostname'] = &quot;localhost&quot;;
$db['default']['username'] = &quot;root&quot;;
$db['default']['password'] = &quot;&quot;;
$db['default']['database'] = &quot;ci_extjs_login&quot;;
</pre>
<p>Setting the config file, open file <em>&#8220;system/application/config/config.php&#8221;</em>,<em> </em>my <em>base_url</em> setting is like this (set the value to <em>&#8220;http://localhost/ci_extjs_login/&#8221;</em>)</p>
<pre class="brush: php;">
$config['base_url'] = &quot;http://localhost/ci_extjs_login/&quot;;
</pre>
<p>Setting the autoload file, open file <em>&#8220;system/application/config/autoload.php&#8221;</em>, in this file set the default loaded helpers and libraries to be loaded by the application</p>
<pre class="brush: php;">
$autoload['libraries'] = array('database', 'session', 'my_usession');
</pre>
<p>As you can see above, the <em>&#8220;database&#8221;</em> and <em>&#8220;session&#8221;</em>, are the default codeigniter library, for &#8220;my_usession&#8221; i&#8217;m using my own library it&#8217;s pretty simple to implement, to see more you can read my <a href="http://superdit.com/2010/04/17/creating-user-session-checking-with-codeigniter-library/" target="_blank">previous post</a>, next to load the url codeigniter helper, this will help when you linking a page to the server in Extjs.</p>
<pre class="brush: php;">$autoload['helper'] = array('url');</pre>
<p>Setting the route file, open file <em>&#8220;system/application/config/routes.php&#8221;</em>, change the default controller to &#8220;user&#8221; even though in this step we haven&#8217;t create the file yet</p>
<pre class="brush: php;">$route['default_controller'] = &quot;user&quot;;</pre>
<p><strong>3. Adding the Extjs file to in Codeigniter</strong></p>
<p><a href="http://superdit.com/wp-content/uploads/2010/06/ci_extjs_folder_structure1.png"><img class="size-full wp-image-727 alignright" title="ci_extjs_folder_structure" src="http://superdit.com/wp-content/uploads/2010/06/ci_extjs_folder_structure1.png" alt="" width="164" height="171" /></a>I usually create the separated folder from system in Codeigniter, create <em>&#8220;assets&#8221;</em> folder to put all images, css and javascript file, so you can put all the Extjs file in the js folder, as you can see on the image in the right. All Extjs file placed in the <em>&#8220;ext&#8221;</em> folder and the <em>&#8220;ext_plugins&#8221;</em> folder is the where I usually placed the plugins. You can see <em>&#8220;nbproject&#8221; </em>folder, this is the auto generated folder when you are developing project using <a title="netbeans" href="http://netbeans.org" target="_blank">netbeans</a>, you can remove it if you are in the production state. The next is to include the Extjs file in every html header, now create view file in codeigniter here <em>&#8220;system/application/views/header.php&#8221; </em>and my code is like this</p>
<pre class="brush: php;">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
    &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;&lt;?php echo base_url(); ?&gt;assets/js/ext/resources/css/ext-all.css&quot;/&gt;

    &lt;script type=&quot;text/javascript&quot; src=&quot;&lt;?php echo base_url(); ?&gt;assets/js/ext/adapter/ext/ext-base.js&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;&lt;?php echo base_url(); ?&gt;assets/js/ext/ext-all.js&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot;&gt;
        var BASE_URL = '&lt;?php echo base_url(); ?&gt;' + 'index.php/';
        var BASE_PATH = '&lt;?php echo base_url(); ?&gt;';
        Ext.onReady(function() {
            Ext.QuickTips.init();
            Ext.BLANK_IMAGE_URL = BASE_PATH + 'assets/js/ext/resources/images/default/s.gif';
            Ext.form.Field.prototype.msgTarget = 'side';
        });
    &lt;/script&gt;

    &lt;style&gt;
    body {
        background:#7F99BE;
    }
    #header {
        border-bottom:1px solid #666;
        background:#1E4176;
        padding:5px;
        color:#fff;
        font-size:20px;
        font-weight:bold;
        font-family:'Lucida Grande', Arial, Sans;
    }
    &lt;/style&gt;
    &lt;title&gt;&lt;?php echo $title; ?&gt;&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
</pre>
<p>As you can see above I&#8217;m using the Codeigniter url helper, <em>base_url()</em> to locate the Extjs file, the defined variable in javascript <em>&#8220;BASE_URL&#8221; </em>and <em>&#8220;BASE_PATH&#8221; </em>is useful when requesting server location, you can see on the next step. Now create file for login screen in <em>&#8220;system/application/views/user/login.php&#8221; </em>and add this code</p>
<pre class="brush: php;">
&lt;?php $this-&gt;load-&gt;view('header'); ?&gt;

&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;&lt;?php echo base_url(); ?&gt;assets/js/ext_plugins/statusbar/css/statusbar.css&quot;/&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;&lt;?php echo base_url(); ?&gt;assets/js/ext_plugins/statusbar/StatusBar.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;&lt;?php echo base_url(); ?&gt;assets/js/form_validation.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;&lt;?php echo base_url(); ?&gt;assets/js/form_login.js&quot;&gt;&lt;/script&gt;

&lt;?php $this-&gt;load-&gt;view('footer'); ?&gt;
</pre>
<p>The status bar plugin you can copied from Extjs default example located in <em>&#8220;assets/js/ext/examples/ux/statusbar&#8221; </em>copy all the files inside this folder, actually you can directly link to that folder, but for me it easier to read the plugin that I used in the folder hierarchy. We have not create the two javascript file <em>&#8220;form_validation.js&#8221; </em>and <em>&#8220;form_login.js&#8221; </em>yet, we&#8217;ll create it on the next step, but I always wanted a footer file on the view so create file <em>&#8220;system/application/views/footer.php&#8221; </em>and the code is as simple as this (for this project just to closing the html and body tag)</p>
<pre class="brush: php;">
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Now create the javascript file, in this file we will create two from in the same file, which mean one page, two Extjs windows and two Extjs forms (login and register).  Create file in <em>&#8220;assets/js/form_login.js&#8221; </em>insert this code</p>
<pre class="brush: jscript;">
Ext.onReady(function() {

    /* 01. Start The Form Register Component */

    // 01. Form Register
	var formRegister = new Ext.FormPanel({
		frame: false, border: false, buttonAlign: 'center',
		url: BASE_URL + 'user/ext_register', method: 'POST', id: 'frmRegister',
		bodyStyle: 'padding:10px 10px 15px 15px;background:#dfe8f6;',
		width: 300, labelWidth: 150,
		items: [{
			xtype: 'textfield',
			fieldLabel: 'Username',
			name: 'username',
			id: 'regUsername',
			allowBlank: false,
            vtype: 'uniqueusername'
		}, {
			xtype: 'textfield',
			fieldLabel: 'Password',
			name: 'password',
			allowBlank: false,
			inputType: 'password',
            vtype: 'passwordlength',
            id: 'pass1'
		}, {
			xtype: 'textfield',
			fieldLabel: 'Confirm Password',
			name: 'cpassword',
			allowBlank: false,
			inputType: 'password',
            id: 'pass2',
            initialPassField: 'pass1',
            vtype: 'password'
		}, {
			xtype: 'textfield',
			fieldLabel: 'Email',
            id: 'regEmail',
			name: 'email',
			vtype:'uniqueemail',
			allowBlank: false,
            validationEvent: ''
		}
		],
		buttons: [
			{ text: 'Register', handler: fnRegister },
			{ text: 'Reset', handler: function() {
					formRegister.getForm().reset();
				}
			}
		]
	});

    function fnRegister() {
        Ext.getCmp('frmRegister').on({
            beforeaction: function() {
                if (formRegister.getForm().isValid()) {
                    Ext.getCmp('winRegister').body.mask();
                    Ext.getCmp('winLogin').body.mask();
                    Ext.getCmp('sbWinRegister').showBusy();
                }
            }
        });
        formRegister.getForm().submit({
            success: function() {
                formRegister.getForm().reset();
                Ext.getCmp('sbWinRegister').setStatus({
                    text: 'Registration Success',
                    iconCls: 'x-status-saved'
                });
                Ext.getCmp('winRegister').body.unmask();
                Ext.getCmp('winLogin').body.unmask();
            }
        });
    }

    // 01. Window Register
	var winRegister = new Ext.Window({
		title: 'CI Extjs &amp;mdash; User Register',
        id: 'winRegister',
		layout: 'fit',
		width: 350,
		height: 210,
		y: 120,
		resizable: false,
		closable: false,
		items: [formRegister],
        bbar: new Ext.ux.StatusBar({
            text: 'Ready',
            id: 'sbWinRegister'
        })
	});

	winRegister.show();

    /* 02. Start The Form Login Component */

    // 02. Form Login
    var formLogin = new Ext.FormPanel({
		frame: false, border: false, buttonAlign: 'center',
		url: BASE_URL + 'user/ext_login', method: 'POST', id: 'frmLogin',
		bodyStyle: 'padding:10px 10px 15px 15px;background:#dfe8f6;',
		width: 300, labelWidth: 150,
		items: [{
			xtype: 'textfield',
			fieldLabel: 'Username',
			name: 'username',
			id: 'logUsername',
			allowBlank: false
		}, {
			xtype: 'textfield',
			fieldLabel: 'Password',
			name: 'password',
            id: 'logPassword',
			allowBlank: false,
			inputType: 'password'
		}
		],
		buttons: [
			{ text: 'Login', handler: fnLogin },
			{ text: 'Reset', handler: function() {
					formLogin.getForm().reset();
				}
			}
		]
	});

    function fnLogin() {
        Ext.getCmp('frmLogin').on({
            beforeaction: function() {
                if (formLogin.getForm().isValid()) {
                    Ext.getCmp('winRegister').body.mask();
                    Ext.getCmp('winLogin').body.mask();
                    Ext.getCmp('sbWinLogin').showBusy();
                }
            }
        });
        formLogin.getForm().submit({
           success: function() {
               window.location = BASE_URL;
           },
           failure: function(form, action) {
               Ext.getCmp('winRegister').body.unmask();
               Ext.getCmp('winLogin').body.unmask();
               if (action.failureType == 'server') {
                    obj = Ext.util.JSON.decode(action.response.responseText);
                    Ext.getCmp('sbWinLogin').setStatus({
                        text: obj.errors.reason,
                        iconCls: 'x-status-error'
                    });
                } else {
                    if (formLogin.getForm().isValid()) {
                        Ext.getCmp('sbWinLogin').setStatus({
                            text: 'Authentication server is unreachable',
                            iconCls: 'x-status-error'
                        });
                    } else {
                        Ext.getCmp('sbWinLogin').setStatus({
                            text: 'Something error in form !',
                            iconCls: 'x-status-error'
                        });
                    }
                }
           }
        });
    }

    // 02. Window Login
	var winLogin = new Ext.Window({
		title: 'CI Extjs &amp;mdash; User Login',
        id: 'winLogin',
		layout: 'fit',
		width: 350,
		height: 160,
		y: 340,
		resizable: false,
		closable: false,
		items: [formLogin],
        bbar: new Ext.ux.StatusBar({
            text: 'Ready',
            id: 'sbWinLogin'
        })
	});

	winLogin.show();
});
</pre>
<p>Now for the custom validation file I&#8217;m using the unique field validation from my <a href="http://superdit.com/2010/05/07/unique-field-form-validation-using-php-and-extjs/" target="_blank">previous post</a> and modified a little bit, although is not perfect but still can used in here, so create file <em>&#8220;assets/js/form_validation.js&#8221;</em> and the code is</p>
<pre class="brush: jscript;">
/* Custom Unique Username Validation
 * Used in 01. Form Register */

var usernameErrLength = 'Username minimum 4 character !';
var usernameErrUnique = 'Username already in use !';
var usernameSuccess = 'Username avaliable';
var emailErrFormat = 'Email not valid !';
var emailErrUnique = 'Email already in use !';
var emailSuccess = 'Email valid &amp; avaliable';

Ext.apply(Ext.form.VTypes, {
    uniqueusernameMask : /[a-z0-9_\.\-@\+]/i,
	uniqueusername : function(val) {
        if (val.length &lt; 4) {
            Ext.apply(Ext.form.VTypes, {
                uniqueusernameText: usernameErrLength
            });
            return false;
        } else {
            Ext.Ajax.request({
                url: BASE_URL + 'user/ext_is_unique_username',
                method: 'POST',
                params: 'username=' + val,
                success: function(o) {
                    if (o.responseText == 0) {
                        resetUsernameValidator(false);
                        Ext.apply(Ext.form.VTypes, {
                            uniqueusernameText: usernameErrUnique
                        });
                        return false;
                    } else {
                        resetUsernameValidator(true);
                    }
                }
            });
            return true;
        }
	},
	uniqueusernameText : usernameErrUnique,

    uniqueemailMask : /[a-z0-9_\.\-@\+]/i,
    uniqueemail : function(val) {
        var uniqueemail = /^(\w+)([\-+.][\w]+)*@(\w[\-\w]*\.){1,5}([A-Za-z]){2,6}$/;
        if (uniqueemail.test(val)) {
            Ext.Ajax.request({
                url: BASE_URL + 'user/ext_is_unique_email',
                method: 'POST',
                params: 'email=' + val,
                success: function(o) {
                    if (o.responseText == 0) {
                        resetEmailValidator(false);
                        Ext.apply(Ext.form.VTypes, {
                            uniqueemailText: emailErrUnique
                        });
                    } else {
                        resetEmailValidator(true);
                    }
                }
            });
            return true;
        } else {
            return false;
        }

    },
    uniqueemailText : emailErrFormat,

    password : function(val, field) {
        if (field.initialPassField) {
            var pwd = Ext.getCmp(field.initialPassField);
            return (val == pwd.getValue());
        }
        return true;
    },
    passwordText : 'Passwords do not match',

    passwordlength : function(val) {
        if (val.length &lt; 5) {
            return false;
        } else {
            return true;
        }
    },
    passwordlengthText : 'Password minimum 5 character'
});

function resetUsernameValidator(is_error) {
	Ext.apply(Ext.form.VTypes, {
		uniqueusername : function(val) {
            if (val.length &lt; 4) {
                Ext.apply(Ext.form.VTypes, {
                    uniqueusernameText: usernameErrLength
                });
                return false;
            } else {
                Ext.Ajax.request({
                    url: BASE_URL + 'user/ext_is_unique_username',
                    method: 'POST',
                    params: 'username=' + val,
                    success: function(o) {
                        if (o.responseText == 0) {
                            resetUsernameValidator(false);
                        } else {
                            resetUsernameValidator(true);
                        }
                    }
                });
                return is_error;
            }
		}
	});
}

function resetEmailValidator(value) {
    Ext.apply(Ext.form.VTypes, {
        uniqueemail : function(val) {
            var uniqueemail = /^(\w+)([\-+.][\w]+)*@(\w[\-\w]*\.){1,5}([A-Za-z]){2,6}$/;
            if (uniqueemail.test(val)) {
                Ext.Ajax.request({
                    url: BASE_URL + 'user/ext_is_unique_email',
                    method: 'POST',
                    params: 'email=' + val,
                    success: function(o) {
                        if (o.responseText == 0) {
                            resetEmailValidator(false);
                            Ext.apply(Ext.form.VTypes, {
                                uniqueemailText: emailErrUnique
                            });
                        } else {
                            resetEmailValidator(true);
                        }
                    }
                });
            } else {
                return false;
            }
            return (value);
        }
    });
}
</pre>
<p>The last file in views is index which is called when user is authenticated in <em>&#8220;system/application/views/user/index.php&#8221;, </em>here I&#8217;m using my last project layout using Extjs and I can&#8217;t explain more about this, if you want simple layout just html and php that would be fine, or if you want follow my step you can separate the javascript file from the php file like the way from previous step</p>
<pre class="brush: php;">
&lt;?php $this-&gt;load-&gt;view('header'); ?&gt;

&lt;script type=&quot;text/javascript&quot;&gt;
    var layout_west1 = new Ext.tree.TreePanel({
    region: 'north', title: 'Menus', height: 250, bodyStyle: 'margin-bottom:6px;',
    autoScroll: true, enableDD: false, rootVisible: false, id: 'treePanel',
    root: {
        text: 'Menu',
        expanded: true,
        nodeType: 'async',
        children: [{
            text: 'Menu 1',
            expanded: true,
            children: [{
                text: 'Menu 1.1',
                leaf: true
            }, {
                text: 'Menu 1.2',
                expanded: true,
                children: [{
                    text: 'Menu 1.2.1',
                    leaf: true
                }, {
                    text: 'Menu 1.2.2',
                    leaf: true
                }, {
                    text: 'Menu 1.2.3',
                    leaf: true
                }]
            }]
        }, {
            text: 'Menu 2',
            expanded: true,
            children: [{
                text: 'Menu 2.1',
                leaf: true
            }, {
                text: 'Menu 2.2',
                leaf: true
            }]
        }, {
            text: 'Logout',
            id: 'logout',
            icon: BASE_PATH + 'assets/img/icons/minus-circle.png',
            leaf: true
        }]
    },
    listeners: {
        click: function(n) {
            switch (n.id) {
                case 'logout':
                    do_logout();
                    break;
            }
        }
    }
});

var layout_west2 = new Ext.Panel({
	region: 'center', margin: '10 0 0 0', autoScroll: true,
	bodyStyle: 'padding:10px;background:#eee;font-family:&quot;Lucida Grande&quot;',
	html: '&lt;p style=&quot;padding:20px;text-align:center;color:#666;font-size:14px;border:1px dotted #999;background:#fff;&quot;&gt;\n\
            &lt;img src=&quot;public/img/btn-left.jpg&quot;/&gt;&lt;br/&gt; CodeIgniter - Extjs &lt;br/&gt;&lt;span style=&quot;font-size:11px;&quot;&gt;Simple Login Screen&lt;/span&gt;&lt;/p&gt;'
});

var tab_center = new Ext.TabPanel({
    xtype: 'tabpanel', resizeTabs: false, minTabWidth: 115, tabWidth: 135,
    enableTabScroll: true, layoutOnTabChange: true, border: false,
    activeItem: 'tab_welcome', autoDestroy: false,
    items: [
        { xtype: 'panel', id: 'tab_welcome', bodyStyle: 'padding:10px', title: 'Welcome' }
    ]
});

var tbCenter = new Ext.Toolbar({
    items: ['-&gt;', {
        icon: BASE_PATH + 'assets/img/icons/minus-circle.png',
        text: 'Logout',
        handler: do_logout
    }]
});

var layout_center = new Ext.Panel({
    id: 'content-panel', region: 'center', layout: 'card', margins: '0 5 5 0',
    activeItem: 0, border: true, tbar: tbCenter, items: [tab_center]
});

var layout_main = new Ext.Viewport({
	layout: 'border', renderTo: Ext.getBody(),
	items: [
        { region: 'north', autoHeight: true, height: 100, border: false,
            html: '&lt;div id=&quot;header&quot;&gt;CodeIgniter - Extjs&lt;span style=&quot;font-size:12px;&quot;&gt;Simple Login Screen&lt;/span&gt;&lt;/div&gt;',
            margins: '0 0 5 0', style: 'border-bottom: 4px solid #4c72a4;' },
        { region: 'west', baseCls: 'x-plain', xtype: 'panel', autoHeight: true,
            width: 180, border: false,
            split: true, margins: '0 0 0 5', items: [layout_west1, layout_west2]
        }, layout_center]
});

function do_logout() {
    Ext.Ajax.request({
        url: BASE_URL + 'user/ext_logout',
        method: 'POST',
        success: function(xhr) {
            window.location = BASE_URL + 'user/login';
        }
    });
}

layout_main.show();
&lt;/script&gt;

&lt;?php $this-&gt;load-&gt;view('footer'); ?&gt;
</pre>
<p><strong>4. Create controller</strong></p>
<p>Create the controller file user.php in <em>&#8220;system/application/controllers/user.php&#8221;</em></p>
<pre class="brush: php;">
&lt;?php

class User extends Controller {

    public function __construct()
    {
        parent::Controller();
    }

    public function index()
    {
        if ($this-&gt;my_usession-&gt;logged_in)
        {
            $data['title'] = 'User Index';
            $this-&gt;load-&gt;view('user/index', $data);
        }
        else
        {
            redirect('user/login');
        }
    }

    public function login()
    {
        if ($this-&gt;my_usession-&gt;logged_in)
        {
            redirect('user/index');
        }
        else
        {
            $data['title'] = 'User Login';
            $this-&gt;load-&gt;view('user/login', $data);
        }
    }

    public function ext_is_unique_username()
    {
        $cond = array('username' =&gt; $_POST['username']);
        $query = $this-&gt;db-&gt;get_where('users', $cond);
        if ($query-&gt;num_rows() != 0)
        {
            echo 0;
        }
        else
        {
            echo 1;
        }
    }

    public function ext_is_unique_email()
    {
        $cond = array('email' =&gt; $_POST['email']);
        $query = $this-&gt;db-&gt;get_where('users', $cond);
        if ($query-&gt;num_rows() != 0)
        {
            echo 0;
        }
        else
        {
            echo 1;
        }
    }

    public function ext_logout()
    {
        $this-&gt;my_usession-&gt;unset_userdata(&quot;user_id&quot;);
        echo &quot;{success:true}&quot;;
    }

    public function ext_login()
    {
        $cond = array(
            'username' =&gt; $_POST['username'],
            'password' =&gt; $_POST['password']
        );
        $query = $this-&gt;db-&gt;get_where('users', $cond);
        if ($query-&gt;num_rows() != 0)
        {
            $row = $query-&gt;row();
            $this-&gt;my_usession-&gt;set_userdata('user_id', $row-&gt;id);
            $this-&gt;my_usession-&gt;set_userdata('username', $row-&gt;username);
            echo &quot;{success:true}&quot;;
        }
        else
        {
            echo &quot;{success:false, errors: { reason: 'User not found !' }}&quot;;
        }
    }

    public function ext_register()
    {
        $data = array(
            'username' =&gt; $_POST['username'],
            'password' =&gt; $_POST['password'],
            'email' =&gt; $_POST['email']
        );
        $this-&gt;db-&gt;insert('users', $data);

        echo &quot;{success:true}&quot;;
    }

}
</pre>
<p>The final result should look like this</p>
<p style="text-align: center;"><img class="size-full wp-image-768  aligncenter" title="ci_extjs_login_form" src="http://superdit.com/wp-content/uploads/2010/06/ci_extjs_login_form.png" alt="" width="365" height="397" /></p>
<p style="text-align: center;">default login and register form in <em>&#8220;http://localhost/ci_extjs_login/index.php/user/login&#8221;</em></p>
<p style="text-align: center;"><img class="aligncenter" src="http://i49.tinypic.com/1zycxuh.jpg" alt="" width="639" height="324" /></p>
<p style="text-align: center;">default index layout in <em>&#8220;http://localhost/ci_extjs_login/index.php/&#8221;</em></p>
<p>Like always I provide the source to be downloaded but, not included the Extjs file, you have to download yourself from the official site <a title="extjs" href="http://extjs.com" target="_blank">here</a>.</p>
<p><strong><a href="http://www.box.net/shared/jy49ysa5on" target="_blank">DOWNLOAD SOURCE</a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://superdit.com/2010/06/02/creating-register-and-login-form-using-extjs-and-codeigniter/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>EXTJS: Window Form Masking With Statusbar</title>
		<link>http://superdit.com/2010/05/24/extjs-window-form-masking-with-statusbar/</link>
		<comments>http://superdit.com/2010/05/24/extjs-window-form-masking-with-statusbar/#comments</comments>
		<pubDate>Mon, 24 May 2010 03:20:32 +0000</pubDate>
		<dc:creator>aditia rahman</dc:creator>
				<category><![CDATA[Extjs]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[masking]]></category>

		<guid isPermaLink="false">http://superdit.com/?p=586</guid>
		<description><![CDATA[In this tutorial i want to show you how to masking a form when user enter a submit button, statusbar that used in this tutorial is from the Extjs ux example, so I borrow this cause it is useable plugin, like always on the server side process I use simple PHP scripting. I created this [...]]]></description>
			<content:encoded><![CDATA[<p>In this tutorial i want to show you how to masking a form when user enter a submit button, statusbar that used in this tutorial is from the Extjs ux example, so I borrow this cause it is useable plugin, like always on the server side process I use simple PHP scripting. I created this post because when I used a form in Extjs and the user make a request it seem not really responsive, the system should interact the user, inform what is going on in the system and most user is not advance user. Let&#8217;s get started:</p>
<p><strong>1. Setting the StatusBar</strong></p>
<p><img class="size-full wp-image-594 alignright" title="ext_form_file_structure" src="http://superdit.com/wp-content/uploads/2010/05/ext_form_file_structure.png" alt="" width="186" height="203" /></p>
<p style="text-align: left;">Copy the StatusBar css file and icon from the default examples to your desired folder,  first the css file you can find it in &#8220;<em>e</em><em>xtjs/examples/ux/statusbar/css/statusbar.css&#8221;, </em>I copy it to another folder called &#8220;css&#8221;<em> </em>and next the statusbar icon is in &#8220;<em>/extjs/examples/ux/statusbar/images&#8221; </em>and I copy all the icon files to another folder called &#8220;img&#8221; most the file structure you can see it on the image on the right, this is how it look in Netbeans project. You can see the &#8220;<em>form_masking.html&#8221;</em> and &#8220;<em>server_response.php&#8221;</em> file, this is the main file that we have to create, and it will be mentioned on the next step, but before that we have to edit the StatusBar.css file that we have copied so the icon can be loaded, by changing the &#8220;<em>background-image</em>&#8221; properties. So find this all code like this<span id="more-586"></span></p>
<pre class="brush: css;">
background-image: url(../images/loading.gif);
</pre>
<p>Change the background-image to to this code, and do this to all background-image but you only need to change the url path not the image file</p>
<pre class="brush: css;">
background-image: url(../img/loading.gif);
</pre>
<p><strong>2. Create the main file</strong></p>
<p>Like usual include EXTJS file in your html header, but this time you need to include the StatusBar.css that you have modified and the StatusBar.js (I don&#8217;t modified this file, this file directly linked from the Extjs ux examples, you can found it bundled on the examples)</p>
<pre class="brush: xml;">
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;extjs/resources/css/ext-all.css&quot;/&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;css/StatusBar.css&quot;/&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;extjs/adapter/ext/ext-base.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;extjs/ext-all.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;extjs/examples/ux/statusbar/StatusBar.js&quot;&gt; &lt;/script&gt;
</pre>
<p><strong>3. Create the Form, Function Handler and the Window</strong></p>
<p>I Create a file named &#8220;form_masking.html&#8221;, the form is similar to the form from <a href="http://superdit.com/2010/05/07/unique-field-form-validation-using-php-and-extjs/" target="_blank">the previous post</a>, but in this code I added the key EventObject on the form, so when user press enter on the form, it will submit the form like the traditional html form</p>
<pre class="brush: jscript;">
&lt;script type=&quot;text/javascript&quot;&gt;
Ext.onReady(function(){
    var formMasking = new Ext.FormPanel({
        frame: false, border: false, buttonAlign: 'center',
        url: 'server_response.php', method: 'POST', id: 'frmMasking',
        bodyStyle: 'padding:10px 10px 15px 15px;background:#dfe8f6;',
        labelWidth: 150, width: 300,
        items: [{
                xtype: 'textfield',
                fieldLabel: 'Username',
                name: 'username',
                id: 'formUsername',
                allowBlank: false
            }, {
                xtype: 'textfield',
                fieldLabel: 'Password',
                name: 'password',
                id: 'formPassword',
                allowBlank: false,
                inputType: 'password'
            }
        ],
        keys: [
            { key: [Ext.EventObject.ENTER], fn: fnLogin }
        ],
        buttons: [
            { text: 'Login', handler: fnLogin },
            { text: 'Reset', handler: function() {
                    formMasking.getForm().reset();
                }
            }
        ]
    });

    function fnLogin() {
        // this function must before
        Ext.getCmp('frmMasking').on({
            beforeaction: function() {
                Ext.getCmp('winMask').body.mask();
                Ext.getCmp('sbWin').showBusy();
            }
        });

        formMasking.getForm().submit({
            success: function() {
                Ext.getCmp('winMask').body.unmask();
                Ext.getCmp('sbWin').setStatus({
                    text: 'Login success !',
                    iconCls: 'x-status-valid'
                });
            },
            failure: function(form, action) {
                Ext.getCmp('winMask').body.unmask();
                if (action.failureType == 'server') {
                    obj = Ext.util.JSON.decode(
                        action.response.responseText);
                    Ext.getCmp('sbWin').setStatus({
                        text: obj.errors.reason,
                        iconCls: 'x-status-error'
                    });
                } else {
                    if (typeof(action.response) == 'undefined') {
                        Ext.getCmp('sbWin').setStatus({
                            text: 'Field cannot be empty !',
                            iconCls: 'x-status-error'
                        });
                    } else {
                        Ext.Msg.alert('Warning!',
                            'Server is unreachable : '
                                + action.response.responseText);
                    }
                }
            }
        });
    }

    var winMasking = new Ext.Window({
        title: 'EXTJS &amp;mdash; Window Masking', layout: 'fit',
        width: 350, height: 150, resizable: false, closable: false,
        items: [formMasking], id:'winMask',
        bbar: new Ext.ux.StatusBar({
            text: 'Ready',
            id: 'sbWin',
            iconCls: 'x-status-saved'
        })
    });

    winMasking.show();
});
&lt;/script&gt;
</pre>
<p><strong>4. The Function Handler</strong></p>
<p>The function handler name is &#8220;fnLogin&#8221; as you can see on the code above (on the step 3), when the form submitted the event on beforeaction is called an it masking the window, why not mask the form? because when I try mask the form it will only masked the fieldLabel and the textField but not the button, so just mask the window and it will mask everything inside it. The beforeaction event have to be defined before the form submit function, or it wil not work.</p>
<p><strong>5. Create The Server Response</strong></p>
<p>I Create a file named &#8220;server_response.php&#8221;, the php code is the same as <a href="http://superdit.com/2010/05/07/unique-field-form-validation-using-php-and-extjs/" target="_blank">the previous post</a>, it just checking username from the hardcoded array.</p>
<pre class="brush: php;">
&lt;?php

$username_list = array('admin', 'administrator', 'superadmin', 'john', 'michael');
if (in_array($_POST['username'], $username_list)) {
    echo &quot;{success:true}&quot;;
}
else {
    echo &quot;{success:false, errors: { reason: 'User not found !' }}&quot;;
}

?&gt;
</pre>
<p>The expected screen should be like the image below, the form when in the default condition, loading, give the error message, and when the success is achieved.</p>
<p style="text-align: center;"><img class="size-full wp-image-628    aligncenter" title="001_ext_form_form_masking_html_default" src="http://superdit.com/wp-content/uploads/2010/05/001_ext_form_form_masking_html_default.png" alt="" width="378" height="180" /></p>
<p style="text-align: center;"><img class="size-full wp-image-629  aligncenter" src="http://superdit.com/wp-content/uploads/2010/05/002_ext_form_form_masking_html_loading.png" alt="" width="378" height="180" /></p>
<p style="text-align: center;"><img class="size-full wp-image-630  aligncenter" src="http://superdit.com/wp-content/uploads/2010/05/003_ext_form_form_masking_html_failed.png" alt="" width="378" height="180" /></p>
<p style="text-align: center;"><img class="size-full wp-image-631  aligncenter" src="http://superdit.com/wp-content/uploads/2010/05/004_ext_form_form_masking_html_invalid.png" alt="" width="378" height="180" /></p>
<p style="text-align: center;"><img class="size-full wp-image-632        aligncenter" src="http://superdit.com/wp-content/uploads/2010/05/005_ext_form_form_masking_html_success.png" alt="" width="378" height="180" /></p>
<p style="text-align: left;">If you want another form load masking example there a sample by Saki <a href="http://examples.extjs.eu/?ex=formloadsubmit" target="_blank">here</a> (I think it is more advanced), or if you like to add more advance StatusBar validation you can learn the official samples <a href="http://www.extjs.com/deploy/dev/examples/statusbar/statusbar-advanced.html" target="_blank">here</a>. Finally like always I provide the code the be downloaded but I&#8217;m not included the Extjs file, you can download it from the official website, <a title="extjs" href="http://extjs.com" target="_blank">here</a>.</p>
<p><a href="http://www.box.net/shared/adfvkdyjqm" target="_blank">DOWNLOAD SOURCE</a></p>
]]></content:encoded>
			<wfw:commentRss>http://superdit.com/2010/05/24/extjs-window-form-masking-with-statusbar/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>EXTJS: Getting each row value from the grid</title>
		<link>http://superdit.com/2010/05/14/extjs-getting-each-row-value-from-the-grid/</link>
		<comments>http://superdit.com/2010/05/14/extjs-getting-each-row-value-from-the-grid/#comments</comments>
		<pubDate>Fri, 14 May 2010 02:44:12 +0000</pubDate>
		<dc:creator>aditia rahman</dc:creator>
				<category><![CDATA[Extjs]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[grid]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://superdit.com/?p=495</guid>
		<description><![CDATA[When I write this post, a friend of mine asking me how to get the value from all the row in EXTJS grid, she use EditorGridPanel to make the grid editable by it&#8217;s user, and submit all edited value in each row to the server  i&#8217;m using php to take all the server side process). [...]]]></description>
			<content:encoded><![CDATA[<p>When I write this post, a friend of mine asking me how to get the value from all the row in <a title="extjs" href="http://extjs.com/" target="_blank">EXTJS</a> grid, she use EditorGridPanel to make the grid editable by it&#8217;s user, and submit all edited value in each row to the server  i&#8217;m using php to take all the server side process). Actually the idea is very simple, the grid need to have <em>sm</em> config options it is a shorthand for <em>selModel</em> and this config that make the grid can be selected per row, and you can added the <em>checkboxselection </em>model to choose the row that you desired, so trid to make it simple tutorial, and at the of the post you can download the source from this post.</p>
<p><strong>1. Setting the main page</strong><br />
Include the EXTJS file (javascript and css) in html header file, then create single div with an id to where the grid to put on, and i&#8217;m using inline css style to centering the div the on the page</p>
<pre class="brush: jscript;">
&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Transitional//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
&lt;head&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;extjs/resources/css/ext-all.css&quot;/&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;extjs/adapter/ext/ext-base.js&quot;; ?&gt;&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;extjs/ext-all.js&quot;; ?&gt;&quot;&gt;&lt;/script&gt;
&lt;/head&gt;

/* This should be fill with the EXTJS script code
 * It explain on the next step
 */

// on the body section
&lt;body&gt;
&lt;div id=&quot;grid-example1&quot; style=&quot;height: 200px;width:600px;margin:0 auto;padding:20px;&quot;&gt;&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p><span id="more-495"></span></p>
<p><strong>2. Create the data in array for store inside the grid</strong><br />
To make it simple I using data for grid from an array, for more expert use, maybe using Json data reader will be fit</p>
<pre class="brush: jscript;">
var myData = [
	[1, 'Luffy', 'Monkey D Luffy', 'monkeyd@luffy.com', 'East Blue'],
	[2, 'Zoro', 'Roronoa Zoro', 'roronoa@zoro.com', 'East Blue'],
	[3, 'Sanji', 'Leg Sanji', 'sanji@baratie.net', 'East Blue'],
	[4, 'Usop', 'Soge King', 'usap@sogevillage.com', 'East Blue'],
	[5, 'Franky', 'Franky Cyborg', 'franky@water7.com', 'East Blue'],
	[6, 'Chopper', 'Tony Chopper', 'chopper@drum.com', 'East Blue']
];
</pre>
<p><strong>3. Create the data store for editable grid, in this case i&#8217;m using Form.ComboBox</strong></p>
<pre class="brush: jscript;">
// main store for grid
var store_mbti = new Ext.data.ArrayStore({
	fields: [
		{ name: 'id' }, { name: 'username' }, { name: 'full_name' },
		{ name: 'email' }, { name: 'village' }
	]
});

// store including the data for editable grid, using Form.ComboBox
var strVillage = new Ext.data.SimpleStore({
	fields: ['village'],
	data : [['Baratie'], ['Drum Island'],
		['Soge Island'],['Swordmen Land']]
});
</pre>
<p><strong>4. Create the checkboxselectionmodel</strong><br />
This component have to be created and included in grid config options named <em>sm</em>, the <em>selModel, </em>this is to make the entire single row selectable</p>
<pre class="brush: jscript;">
var cb_select = new Ext.grid.CheckboxSelectionModel();
</pre>
<p><strong>5. Create the main grid component</strong><br />
If you want the grid to be manually selectable by the user you need to add <em>cb_select </em>in the grid column header</p>
<pre class="brush: jscript;">
var grid_mbti = new Ext.grid.EditorGridPanel({
	store: store_mbti,  frame: true, border: true, autoHeight: true,
	resizable: true, loadMask: true, stripeRows: true,
	title:'Grid Select All', sm: cb_select,
	columns: [
		// cb_select, // uncomment, if using checkboxselectionmodel
		{ header: &quot;Username&quot;, dataIndex: 'username', },
		{ header: &quot;Full Name&quot;, dataIndex: 'full_name', width: 150 },
		{ header: &quot;Email&quot;, dataIndex: 'email', width: 150 },
		{ header: &quot;Village&quot;, dataIndex: 'village', width: 120,
			editor: new Ext.form.ComboBox({
				allowBlank: false,
				mode: 'local',
				store: strVillage,
				valueField: 'village',
				displayField: 'village',
				triggerAction: 'all',
				editable: false
			})
		}],
	tbar: [{
		text: 'Submit',
		handler: function() {
			// the implementation is in the next step
		}
	}]
});
</pre>
<p><strong>6. Load the store and render the grid</strong></p>
<pre class="brush: jscript;">
store_mbti.loadData(myData);
grid_mbti.render('grid-example1');
</pre>
<p>The alternative way from using render grid is, to add config option on grid named <em>renderTo</em> and fill it with html id that you desire</p>
<p><strong>7. Function handling on the toolbar, using ajax or not it&#8217;is up to you</strong><br />
Creating function handler should be in handler config in toolbar button, when I try my self it got some error on firebug</p>
<pre class="brush: jscript;">
// this implementation is inside button handler on step 5
handler: function() {
	grid_mbti.getSelectionModel().selectAll();
	var sm = grid_mbti.getSelectionModel().getSelections();
	var temp = '';
	for (i=0; i&lt;=sm.length-1; i++) {
		temp = temp + '|' + sm[i].get('village')
	}
	Ext.Ajax.request({
		url: 'process_data.php',
		method: 'POST',
		params: 'village=' + temp,
		success: function(obj) {
			var resp = obj.responseText;
			if (resp != 0) {
				Ext.MessageBox.alert('Success', resp + ' Processed');
			} else {
				Ext.MessageBox.alert('Failed', 'No Processed');
			}
		}
	});
}
</pre>
<p><strong>8. Handling the server side process</strong><br />
Like the previous step, the php file I called is <em>process_data.php, </em>the php script convert the variable received to an array, and then you can loop through the array</p>
<pre class="brush: php;">
&lt;?php

$arr_village = explode('|', $_POST['village']);
$count = count($arr_village) - 1;
if ($count != 0) {
    foreach ($arr_village as $value) {
        // data process in here, manipulate db or whatever
    }
    echo $count;
} else {
    echo 0;
}

?&gt;
</pre>
<p>The result screen should be like this, first before submit with the last one column editable</p>
<p style="text-align: center;"><img class="size-full wp-image-529 aligncenter" src="http://superdit.com/wp-content/uploads/2010/05/gridEditor_extjs.jpg" alt="" width="634" height="246" /></p>
<p>And after click the submit button on the top left of the grid toolbar, all the row in the grid should be selected</p>
<p><img class="aligncenter size-full wp-image-531" title="gridEditor_extjs2" src="http://superdit.com/wp-content/uploads/2010/05/gridEditor_extjs2.jpg" alt="" width="624" height="234" /></p>
<p>Yup that&#8217;s all, you can download all the code from the link below but once again i&#8217;m not included the <a title="extjs" href="http://extjs.com" target="_blank">EXTJS</a> file, you just can download it by your self on the official site. In the downloaded code I provide 2 grid with different use of selection model so you can clearly see the different, and I welcome for any suggestion from you thanks.</p>
<p><a title="Download Source" href="http://www.box.net/shared/ay7j8mlher" target="_blank">DOWNLOAD SOURCE</a></p>
]]></content:encoded>
			<wfw:commentRss>http://superdit.com/2010/05/14/extjs-getting-each-row-value-from-the-grid/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Unique Field Form Validation Using PHP and EXTJS</title>
		<link>http://superdit.com/2010/05/07/unique-field-form-validation-using-php-and-extjs/</link>
		<comments>http://superdit.com/2010/05/07/unique-field-form-validation-using-php-and-extjs/#comments</comments>
		<pubDate>Fri, 07 May 2010 10:10:41 +0000</pubDate>
		<dc:creator>aditia rahman</dc:creator>
				<category><![CDATA[Extjs]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://superdit.com/?p=464</guid>
		<description><![CDATA[In this post I try to share my code about form validation in EXTJS, so why another EXTJS form validation tutorial? well, the EXTJS default form validation is quite great, but most sample that I&#8217;ve found it just using client side validation and the only server side validation is when the user press submit button. [...]]]></description>
			<content:encoded><![CDATA[<p>In this post I try to share my code about form validation in <a title="EXTJS" href="http://www.extjs.com" target="_blank">EXTJS</a>, so why another EXTJS form validation tutorial? well, the EXTJS default form validation is quite great, but most sample that I&#8217;ve found it just using client side validation and the only server side validation is when the user press submit button. So in this post the I modified a bit code about custom form validation in EXTJS, and here I&#8217;m not using database. The expected result should be like this</p>
<p><img title="php-extjs-validation-screen" src="http://superdit.com/wp-content/uploads/2010/05/php-extjs-validation-screen.jpg" alt="" width="537" height="242" /><span id="more-464"></span></p>
<p>Let&#8217;s start :</p>
<p><strong>1. Include EXTJS file in html header</strong></p>
<pre class="brush: php;">
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;extjs/resources/css/ext-all.css&quot;/&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;extjs/adapter/ext/ext-base.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;extjs/ext-all.js&quot;&gt;&lt;/script&gt;
</pre>
<p><strong>2. Create The EXTJS form</strong></p>
<pre class="brush: jscript;">
&lt;script type=&quot;text/javascript&quot;&gt;
Ext.onReady(function(){
	var formRegister = new Ext.FormPanel({
		frame: false, border: false, buttonAlign: 'center',
		url: 'undefined', method: 'POST', id: 'frmRegister',
		bodyStyle: 'padding:10px 10px 15px 15px;background:#dfe8f6;',
		width: 300, labelWidth: 150,
		items: [{
			xtype: 'textfield',
			fieldLabel: 'Username',
			name: 'username',
			id: 'regUsername',
			allowBlank: false,
			vtype: 'uniqueusername'
		}, {
			xtype: 'textfield',
			fieldLabel: 'Password',
			name: 'password',
			allowBlank: false,
			inputType: 'password'
		}, {
			xtype: 'textfield',
			fieldLabel: 'Confirm Password',
			name: 'cpassword',
			allowBlank: false,
			inputType: 'password'
		}, {
			xtype: 'textfield',
			fieldLabel: 'Email',
			name: 'email',
			vtype:'email',
			allowBlank: false
		}
		],
		buttons: [
			{ text: 'Register' },
			{ text: 'Reset', handler: function() {
					formRegister.getForm().reset();
				}
			}
		]
	});

	var winRegister = new Ext.Window({
		title: 'CI_EXTJS &amp;mdash; User Register',
		layout: 'fit',
		width: 350,
		height: 190,
		y: 260,
		resizable: false,
		closable: false,
		items: [formRegister]
	});

	winRegister.show();
});
&lt;/script&gt;
</pre>
<p><strong>3. Code for modified custom validation</strong><br />
The idea is overiding the custom validation everytime it called</p>
<pre class="brush: jscript;">
&lt;script type=&quot;text/javascript&quot;&gt;
Ext.apply(Ext.form.VTypes, {
	uniqueusername : function(val, field) {
		var username = Ext.getCmp('regUsername').getValue();
		Ext.Ajax.request({
			url: 'check_username.php',
			method: 'POST',
			params: 'username=' + username,
			success: function(o) {
				if (o.responseText == 0) {
					setusernamevalidfalse();
				}
			}
		});
		return true;
	},

	uniqueusernameText : 'Username Already In Use'
});

function setusernamevalidfalse() {
	Ext.apply(Ext.form.VTypes, {
		uniqueusername : function(val, field) {
			var username = Ext.getCmp('regUsername').getValue();
			Ext.Ajax.request({
				url: 'check_username.php',
				method: 'POST',
				params: 'username=' + username,
				success: function(o) {
					if (o.responseText == 0) {
						setusernamevalidfalse();
					} else {
						setusernamevalidtrue();
					}
				}
			});
			return false;
		}
	});
}

function setusernamevalidtrue() {
	Ext.apply(Ext.form.VTypes, {
		uniqueusername : function(val, field) {
			var username = Ext.getCmp('regUsername').getValue();
			Ext.Ajax.request({
				url: 'check_username.php',
				method: 'POST',
				params: 'username=' + username,
				success: function(o) {
					if (o.responseText == 0) {
						setusernamevalidfalse();
					} else {
						setusernamevalidtrue();
					}
				}
			});
			return true;
		}
	});
}
&lt;/script&gt;
</pre>
<p><strong>4. The simple php file validation</strong><br />
For more advanced usage you can use some database connection, and I call it <em>check_username.php</em></p>
<pre class="brush: php;">
&lt;?php

$username_list = array('admin', 'administrator', 'superadmin', 'john', 'michael');
if (in_array($_POST['username'], $username_list)) {
	echo 0;
} else {
	echo 1;
}

?&gt;
</pre>
<p>You can download all files following the download link below, but i&#8217;m included EXTJS file you can download from the official site <a href="http://www.extjs.com/products/js/download.php" target="_blank">here</a>.</p>
<p><strong><a href="http://www.box.net/shared/g3u6ulcies" target="_blank"><strong>DOWNLOAD SOURCE</strong></a></strong></p>
]]></content:encoded>
			<wfw:commentRss>http://superdit.com/2010/05/07/unique-field-form-validation-using-php-and-extjs/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Simple steps to understanding ExtJS</title>
		<link>http://superdit.com/2009/08/21/simple-steps-to-understanding-extjs/</link>
		<comments>http://superdit.com/2009/08/21/simple-steps-to-understanding-extjs/#comments</comments>
		<pubDate>Fri, 21 Aug 2009 02:39:40 +0000</pubDate>
		<dc:creator>aditia rahman</dc:creator>
				<category><![CDATA[Extjs]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[framework]]></category>

		<guid isPermaLink="false">http://superdit.com/?p=113</guid>
		<description><![CDATA[ExtJS is one of the most popular javascript user interface framework, it offer a bunch of great user interface component, if you are a Java Programmer it better you use the Ext-GWT, but if you are a web programmer who always using web scripting language such as PHP, it may be painless if you learn [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://extjs.com" target="_blank">ExtJS</a> is one of the most popular javascript user interface framework, it offer a bunch of great user interface component, if you are a Java Programmer it better you use the Ext-GWT, but if you are a web programmer who always using web scripting language such as PHP, it may be painless if you learn the new web interface beside the traditional HTML, but i did it and mix it with <a href="http://codeigniter.com" target="_blank">Codeigniter</a> in purpose to create and maintain better PHP code, and it&#8217;s not really bad and here some advice I have for you :</p>
<p><strong>1. Follow the examples</strong></p>
<p><img class="size-medium wp-image-124 alignleft" title="Ext-Examples" src="http://superdit.com/wp-content/uploads/2009/08/Ext-Examples-300x183.png" alt="Ext-Examples" width="300" height="183" />ExtJS come with a bunch of great sample use of using widget, this provide the basic use of the component, creating plugin, etc. This is the best way to know what you can do with the component and how to implement the component by viewing the source code, if you somehow don&#8217;t understand what the code means, simply you can consult the API documentation first. Just <a href="http://extjs.com/products/extjs/download.php" target="_blank">download</a> it first and run on your local server or you can view it <a href="http://extjs.com/deploy/dev/examples/samples.html" target="_blank">online</a>.<span id="more-113"></span></p>
<p><strong>2. Read the ExtJS tutorial</strong></p>
<p><a href="http://extjs.com/learn/Tutorials" target="_blank"><img class="size-medium wp-image-126 alignright" title="Tutorials - Learn About the Ext JavaScript Library_1250977156212" src="http://superdit.com/wp-content/uploads/2009/08/Tutorials-Learn-About-the-Ext-JavaScript-Library_1250977156212-300x210.png" alt="Tutorials - Learn About the Ext JavaScript Library_1250977156212" width="240" height="168" /></a>So, you are ready to get your hand wet ? but don&#8217;t know what to do to digging depper to understanding ExtJS, I suggest you start with <a href="http://extjs.com/learn/Tutorials" target="_blank">tutorial</a> from the ExtJS official site. It&#8217;s cover about the getting started guide, dom query helper, combobox, form, grids, drag &amp; drop, menus, tree, etc, even the basic of the application design and some of them provide the downloadable example source code. Although the tutorial is useing version 1.x and 2.x, yes it is compatible if you are using version 3.</p>
<p><strong>3. Don&#8217;t fear to read the API</strong></p>
<p><img class="size-medium wp-image-125 alignleft" title="Ext 3.0 - API Documentation_1250974839663" src="http://superdit.com/wp-content/uploads/2009/08/Ext-3.0-API-Documentation_1250974839663-300x197.png" alt="Ext 3.0 - API Documentation_1250974839663" width="210" height="138" /> The ExtJS API documentation come with the bundle when you&#8217;re downloading ExtJS. So how this gonna be useful ? well for me it provide very useful information about the Ext core and default config options, properties, events, method for each component, it&#8217;s a good reference when you are trying to manipulating the component. Some component given the basic example of usage. Just <a href="http://extjs.com/products/extjs/download.php" target="_blank">download the ExtJS</a> bundle and you can find it in examples folder or you can view it <a href="http://extjs.com/deploy/dev/docs/" target="_blank">online</a></p>
<p><strong>4. Consult the spesific question to the forum</strong></p>
<p><img class="alignleft size-medium wp-image-146" title="extjs reconfigure proxy url - Telusuri dengan Google_1251076695170" src="http://superdit.com/wp-content/uploads/2009/08/extjs-reconfigure-proxy-url-Telusuri-dengan-Google_1251076695170-300x160.png" alt="extjs reconfigure proxy url - Telusuri dengan Google_1251076695170" width="300" height="160" />When I get some trouble I always use Google first, type your spesific question on Google and most of the solution found in the ExtJS official forum and i always found the solution is very handy and easy to understand. Even some of the expert member provide advance source about ExtJS like quick search plugin, grid paging row numberer and custom themes and you can download it for free.</p>
<p><strong>5. Use the good IDE</strong></p>
<p><img class="size-medium wp-image-120 alignleft" title="netbeans-extjs" src="http://superdit.com/wp-content/uploads/2009/08/netbeans-extjs-252x300.png" alt="netbeans-extjs" width="162" height="192" /> Since you use ExtJS in javascript language, the you must code all the ExtJS component by hand, and you need the good IDE to help you browse the all avaliable API. I&#8217;m personally using <a href="http://www.netbeans.org/" target="_blank">Netbeans PHP IDE</a> for my project, you can set the project and include the ExtJS style, ExtJS basic and ExtJS all. The IDE will scan all the project including the ExtJS file and when you code the ExtJS component or ExtJS core, you can type <em>shift + space</em> on your keyboard and the IDE will give an autocomplete feature, and it helping me a lot, maybe not all the method shown in the autocomplete feature but you still can browse on the API documentation. If your not the fan of Netbeans, you can use other great IDE like <a href="http://www.eclipse.org/" target="_blank">Eclipse</a> or <a href="http://aptana.com/" target="_blank">Aptana</a>.</p>
<h5>6. You may need to know a bit about Javascript Language</h5>
<p>My experience is when i code the event handler of the component, sometimes need like client side validation, like is defined object, sel length etc. When you found this trouble just googling about spesific javascript question and it&#8217;is not really hard.</p>
<p><strong>more ExtJS Resource and tutorial</strong></p>
<p><a href="http://extjs.tv" target="_blank">Video tutorial from EXTJS.TV</a> bunch of ExtJS Tutorial</p>
<p><a href="http://defafe.com/" target="_blank">http://defafe.com</a> a blog about ExtJS tutorial</p>
<p><a href="http://www.extforge.org/index.php/2009/examples-of-extjs-in-action/" target="_blank">Example ExtJS in Action</a> some of link not working but the <a href="http://extplorer.sourceforge.net/" target="_blank">ExtPlorer</a> is good.</p>
<p><a href="http://tuturtinular.com/category/extjs/" target="_blank">TuturTinular</a> a blog who have some ExtJS tutorial</p>
<p><a href="http://extjswordpress.net" target="_blank">ExtJS and WordPress</a> wordpress themes usign extjs and it&#8217;s free to download</p>
<p><a href="http://blog.andrekolell.de/2009/04/15/using-an-ext-js-datagrid-with-ajax-in-the-wordpress-administration-panel/" target="_blank">Using ExtJS grid in WordPress Admin</a></p>
<p><a href="http://ragrawal.wordpress.com/2008/12/13/integrating-cakephp-and-extjs-a-complete-guide/" target="_blank">Integrating CakePHP and ExtJS</a></p>
<p><a href="http://blog.extjs.eu/" target="_blank">http://blog.extjs.eu/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://superdit.com/2009/08/21/simple-steps-to-understanding-extjs/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
