<?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; Javascript</title>
	<atom:link href="http://superdit.com/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://superdit.com</link>
	<description>blogging, design, tech, and web</description>
	<lastBuildDate>Thu, 19 Jan 2012 07:50:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<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).<a href="http://superdit.com/2010/05/14/extjs-getting-each-row-value-from-the-grid/" class="read-more">Continue Reading</a>]]></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; title: ; notranslate">
&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; title: ; notranslate">
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; title: ; notranslate">
// 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; title: ; notranslate">
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; title: ; notranslate">
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; title: ; notranslate">
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; title: ; notranslate">
// 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; title: ; notranslate">
&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="507" height="197" /></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 style="text-align: center;"><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="499" height="187" /></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>12</slash:comments>
		</item>
		<item>
		<title>Table sorting collection using prototype javascript</title>
		<link>http://superdit.com/2010/01/31/table-sorting-collection-using-prototype-javascript/</link>
		<comments>http://superdit.com/2010/01/31/table-sorting-collection-using-prototype-javascript/#comments</comments>
		<pubDate>Sun, 31 Jan 2010 01:28:30 +0000</pubDate>
		<dc:creator>aditia rahman</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[prototype]]></category>
		<category><![CDATA[table]]></category>

		<guid isPermaLink="false">http://superdit.com/?p=301</guid>
		<description><![CDATA[In this post I want to show some solution to build sorting table using Prototype Javascript Framework, although the library is not really popular right now (maybe because of Jquery), the community is still live. Most of this script using default style, of course you can customize it. 1. Table Orderer Demo &#124; Download 2. Table<a href="http://superdit.com/2010/01/31/table-sorting-collection-using-prototype-javascript/" class="read-more">Continue Reading</a>]]></description>
			<content:encoded><![CDATA[<p>In this post I want to show some solution to build sorting table using <a href="http://www.prototypejs.org/" target="_blank">Prototype Javascript Framework</a>, although the library is not really popular right now (maybe because of <a href="http://jquery.com/" target="_blank">Jquery</a>), the community is still live. Most of this script using default style, of course you can customize it.</p>
<p><a href="http://prototools.negko.com/demo/tableorderer/" target="_blank"><strong>1. Table Orderer</strong></a></p>
<p><img class="alignnone size-full wp-image-307" src="http://superdit.com/wp-content/uploads/2010/01/table-prototype-01_table-orderer.png" alt="" width="334" height="144" /></p>
<p><a href="http://prototools.negko.com/demo/tableorderer/#Example" target="_blank">Demo</a> | <a href="http://prototools.negko.com/demo/tableorderer/tableorderer.zip">Download</a><span id="more-301"></span></p>
<p><a href="http://www.tom-mack.com/tablesort/" target="_blank"><strong>2. Table Sort</strong></a></p>
<p><img class="alignnone size-full wp-image-308" src="http://superdit.com/wp-content/uploads/2010/01/table-prototype-02_table-sorter.png" alt="" width="444" height="216" /></p>
<p><a href="http://www.tom-mack.com/tablesort/" target="_blank">Demo</a> | <a href="http://www.tom-mack.com/tablesort/sorttableOO.js">Download</a></p>
<p><a href="http://www.millstream.com.au/view/code/tablekit/" target="_blank"><strong>3. Tablekit</strong></a></p>
<p><img class="alignnone size-full wp-image-309" src="http://superdit.com/wp-content/uploads/2010/01/table-prototype-03_tablekit.png" alt="" width="408" height="172" /></p>
<p><a href="http://www.millstream.com.au/upload/code/tablekit/index.html" target="_blank">Demo</a> | <a href="http://www.millstream.com.au/upload/code/tablekit/tablekit1.2.2.zip">Download</a></p>
<p><a href="http://tetlaw.id.au/view/blog/table-sorting-with-prototype/" target="_blank"><strong>4. Table Sorting With Prototype</strong></a></p>
<p><img class="alignnone size-full wp-image-310" src="http://superdit.com/wp-content/uploads/2010/01/table-prototype-04_table-sorting-with-prototype.png" alt="" width="408" height="142" /></p>
<p><a href="http://tetlaw.id.au/upload/pages/table-sorting-with-prototype/" target="_blank">Demo</a> | <a href="http://tetlaw.id.au/upload/pages/table-sorting-with-prototype/tablesort.zip">Download</a></p>
<p><a href="http://rubyizednrailified.blogspot.com/2009/01/lightweight-javascript-table-sorter.html" target="_blank"><strong>5. Lighweight Table Sorting</strong></a></p>
<p><img class="alignnone size-full wp-image-311" src="http://superdit.com/wp-content/uploads/2010/01/table-prototype-05_lightweigth-table-sorting.png" alt="" width="288" height="226" /></p>
<p><a href="http://github.com/toamitkumar/dynamic-javascript-sort-with-prototype/tree/master" target="_blank">Download</a></p>
<p><a href="http://pabloaravena.info/mytablegrid/index.html" target="_blank"><strong>6. MyTableGrid</strong></a></p>
<p><img class="alignnone size-full wp-image-312" src="http://superdit.com/wp-content/uploads/2010/01/table-prototype-06_mytablegrid.png" alt="" width="450" height="304" /></p>
<p><a href="http://pabloaravena.info/mytablegrid/samples/sample1.html" target="_blank">Demo</a> | <a href="http://pabloaravena.info/mytablegrid/MyTableGrid1_0_9.zip" target="_blank">Download</a></p>
<p><a href="http://inventivelabs.com.au/weblog/post/sortable-tables-for-prototype/" target="_blank"><strong>7. Sortable for Prototype</strong></a></p>
<p><img class="alignnone size-full wp-image-313" src="http://superdit.com/wp-content/uploads/2010/01/table-prototype-07_sortable-for-prototype.png" alt="" width="295" height="94" /></p>
<p><a href="http://inventivelabs.com.au/weblog/post/sortable-tables-for-prototype/" target="_blank">Demo</a></p>
]]></content:encoded>
			<wfw:commentRss>http://superdit.com/2010/01/31/table-sorting-collection-using-prototype-javascript/feed/</wfw:commentRss>
		<slash:comments>2</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<a href="http://superdit.com/2009/08/21/simple-steps-to-understanding-extjs/" class="read-more">Continue Reading</a>]]></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>6</slash:comments>
		</item>
	</channel>
</rss>

