<?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>Gustavo Henrique.net &#187; datagrid</title>
	<atom:link href="http://www.gustavohenrique.net/brogui/tag/datagrid/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.gustavohenrique.net/brogui</link>
	<description>Só mais um blog com Wordpress</description>
	<lastBuildDate>Tue, 29 Jun 2010 00:00:51 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>jqDjangoGrid &#8211; plugin JQuery com Django para criar datagrids</title>
		<link>http://www.gustavohenrique.net/brogui/2009/07/jqdjangogrid-plugin-jquery-django-datagrid/</link>
		<comments>http://www.gustavohenrique.net/brogui/2009/07/jqdjangogrid-plugin-jquery-django-datagrid/#comments</comments>
		<pubDate>Fri, 24 Jul 2009 16:26:11 +0000</pubDate>
		<dc:creator>gustavohenrique</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[datagrid]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.gustavohenrique.net/brogui/?p=118</guid>
		<description><![CDATA[jqDjangoGrid é um plugin para JQuery com uma aplicação plugável do Django para criar um datagrid.
Fácil de instalar e customizar, possui ordenação de resultados e pesquisa usando ajax.
Atualmente não suporta recurso de inserir ou alterar registros diretamente no datagrid, mas possui um método genérico para remoção de registros e outro que retorna a PK (Primary [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_119" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.gustavohenrique.net/brogui/wp-content/uploads/2009/07/jqdjangogrid1.jpg"><img src="http://www.gustavohenrique.net/brogui/wp-content/uploads/2009/07/jqdjangogrid-300x158.jpg" alt="Tela do jqDjangoGrid" title="jqdjangogrid" width="300" height="158" class="size-medium wp-image-119" /></a><p class="wp-caption-text">Tela do jqDjangoGrid</p></div>
<p>jqDjangoGrid é um plugin para JQuery com uma aplicação plugável do Django para criar um datagrid.<br />
Fácil de instalar e customizar, possui ordenação de resultados e pesquisa usando ajax.<br />
Atualmente não suporta recurso de inserir ou alterar registros diretamente no datagrid, mas possui um método genérico para remoção de registros e outro que retorna a PK (Primary Key) do objeto selecionado.<br />
<span id="more-118"></span></p>
<h2>INTRODUÇÃO</h2>
<p>Neste artigo mostrarei como é fácil instalar e usar o jqDjangoGrid. Todos os códigos estão comentados para ajudar à quem precisar fazer alguma modificação, por isso eu aconselho a usar algum compactador de código javascript se for usar em ambiente de produção.<br />
O tema padrão é o mesmo utilizado em um artigo anterior sobre datagrid com django, usando tons cinzas e azul. É fácil criar novos temas, bastar alterar o arquivo CSS e substituir as imagens.</p>
<p><del datetime="2009-07-29T12:14:53+00:00">Estou disponibilizando 2 arquivos para download, um contendo apenas o jqDjangoGrid e o outro contendo uma aplicação de exemplo (Um cadastro de bookmarks)</del>. É necessária a biblioteca <a href="http://www.jquery.com" target="_blank">JQuery</a> para funcionar. Os pacotes estão com a versão 1.3.2 dessa biblioteca.</p>
<p>Download:</p>
<p>Baixe a última versão com um exemplo no site github.com.<br />
<a href="http://github.com/gustavohenrique/jqdjangogrid">Código no GitHub</a></p>
<h2>INSTALAÇÃO E UTILIZAÇÃO</h2>
<p>Instalação:</p>
<ol>
<li>Descompacte o pacote jqdjangogrid.tar.gz;</li>
<li>copie o diretório jqdjangogrid, que é a app em django, para o diretório do seu projeto;</li>
<li>Copie os arquivos .js para o diretório de arquivos javascript do seu projeto (dento do MEDIA_ROOT);</li>
<li>Copie o diretório themes para o diretório de arquivos CSS do seu projeto (também dentro do MEDIA_ROOT)</li>
</ol>
<p>Utilização:</p>
<p>Insira jqdjangogrid em INSTALLED_APPS localizada no settings.py e depois crie uma regra no urls.py.</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">INSTALLED_APPS = <span style="color: black;">&#40;</span>
    <span style="color: #808080; font-style: italic;"># outras apps instaladas aqui</span>
    <span style="color: #483d8b;">'jqdjangogrid'</span>,
<span style="color: black;">&#41;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">urlpatterns = patterns<span style="color: black;">&#40;</span><span style="color: #483d8b;">''</span>,
    <span style="color: #808080; font-style: italic;"># suas outras regras aqui</span>
    <span style="color: black;">&#40;</span>r<span style="color: #483d8b;">'^jqdjangogrid/'</span>, include<span style="color: black;">&#40;</span><span style="color: #483d8b;">'jqdjangogrid.urls'</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>,
<span style="color: black;">&#41;</span></pre></div></div>

<p>Inclua uma referência para os arquivos jqdjangogrid.css, jquery.js e jqdjangogrid.js dentro do template HTML principal. Ex.:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-8&quot;&gt;
&lt;link rel=&quot;StyleSheet&quot; type=&quot;text/css&quot; href=&quot;/path_to_your_css/css/themes/default/jqdjangogrid.css&quot;&gt;
&lt;script language=&quot;JavaScript&quot; type=&quot;text/javascript&quot; src=&quot;/path_to_your_js/jquery.js&quot;&gt;&lt;/script&gt;
&lt;script language=&quot;JavaScript&quot; type=&quot;text/javascript&quot; src=&quot;/path_to_your_js/jqdjangogrid.js&quot;&gt;&lt;/script&gt;
...</pre></div></div>

<p>Crie um div qualquer para servir como contâiner para o datagrid.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;div id=&quot;mydatagrid&quot;&gt;&lt;/div&gt;</pre></div></div>

<p>Agora é só criar um objeto datagrid passando as configurações. Abaixo um exemplo com as configurações básicas criado no momento em que a página é carregada:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">&lt;!-- dentro da tag head --&gt;
<span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#mydatagrid'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">datagrid</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #3366CC;">'appLabel'</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'myapp'</span><span style="color: #339933;">,</span>
        <span style="color: #3366CC;">'modelName'</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">'MyClassName'</span><span style="color: #339933;">,</span>
        <span style="color: #3366CC;">'cols'</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #3366CC;">&quot;pk&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;label&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;width&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;10px&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            <span style="color: #3366CC;">&quot;field1&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;label&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Campo 1&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;width&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;100px&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            <span style="color: #3366CC;">&quot;field2&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;label&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Campo 2&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;width&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;300px&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
        <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>Assim, ao carregar a página, será criado um datagrid contendo 3 colunas. Quando o nome da coluna for pk, vai aparecer um radio input cujo valor é a chave primária. Os outros atributos do campo são largura e label que vai aparecer no datagrid.</p>
<p>Conheça outros recursos na próxima página.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em>Compartilhe esse artigo</em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2009%2F07%2Fjqdjangogrid-plugin-jquery-django-datagrid%2F&amp;submitHeadline=jqDjangoGrid+%26%238211%3B+plugin+JQuery+com+Django+para+criar+datagrids&amp;submitSummary=" rel="nofollow" title="Adicionar ao&nbsp;Buzz"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/buzz.png" title="Adicionar ao&nbsp;Buzz" alt="Adicionar ao&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2009%2F07%2Fjqdjangogrid-plugin-jquery-django-datagrid%2F&amp;title=jqDjangoGrid+%26%238211%3B+plugin+JQuery+com+Django+para+criar+datagrids" rel="nofollow" title="Adicionar ao&nbsp;Del.icio.us"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/delicious.png" title="Adicionar ao&nbsp;Del.icio.us" alt="Adicionar ao&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2009%2F07%2Fjqdjangogrid-plugin-jquery-django-datagrid%2F&amp;title=jqDjangoGrid+%26%238211%3B+plugin+JQuery+com+Django+para+criar+datagrids" rel="nofollow" title="Adicionar ao&nbsp;digg"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/digg.png" title="Adicionar ao&nbsp;digg" alt="Adicionar ao&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2009%2F07%2Fjqdjangogrid-plugin-jquery-django-datagrid%2F" rel="nofollow" title="Adicionar ao&nbsp;Facebook"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/facebook.png" title="Adicionar ao&nbsp;Facebook" alt="Adicionar ao&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2009%2F07%2Fjqdjangogrid-plugin-jquery-django-datagrid%2F&amp;title=jqDjangoGrid+%26%238211%3B+plugin+JQuery+com+Django+para+criar+datagrids" rel="nofollow" title="Adicionar ao&nbsp;Google Bookmarks"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/google.png" title="Adicionar ao&nbsp;Google Bookmarks" alt="Adicionar ao&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2009%2F07%2Fjqdjangogrid-plugin-jquery-django-datagrid%2F&amp;bm_description=jqDjangoGrid+%26%238211%3B+plugin+JQuery+com+Django+para+criar+datagrids" rel="nofollow" title="Adicionar ao&nbsp;Mister Wong"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Adicionar ao&nbsp;Mister Wong" alt="Adicionar ao&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2009%2F07%2Fjqdjangogrid-plugin-jquery-django-datagrid%2F&amp;T=jqDjangoGrid+%26%238211%3B+plugin+JQuery+com+Django+para+criar+datagrids" rel="nofollow" title="Adicionar ao&nbsp;Netscape"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/netscape.png" title="Adicionar ao&nbsp;Netscape" alt="Adicionar ao&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2009%2F07%2Fjqdjangogrid-plugin-jquery-django-datagrid%2F&amp;title=jqDjangoGrid+%26%238211%3B+plugin+JQuery+com+Django+para+criar+datagrids" rel="nofollow" title="Adicionar ao&nbsp;reddit"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/reddit.png" title="Adicionar ao&nbsp;reddit" alt="Adicionar ao&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2009%2F07%2Fjqdjangogrid-plugin-jquery-django-datagrid%2F&amp;title=jqDjangoGrid+%26%238211%3B+plugin+JQuery+com+Django+para+criar+datagrids" rel="nofollow" title="Adicionar ao&nbsp;Stumble Upon"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Adicionar ao&nbsp;Stumble Upon" alt="Adicionar ao&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2009%2F07%2Fjqdjangogrid-plugin-jquery-django-datagrid%2F" rel="nofollow" title="Adicionar ao&nbsp;Technorati"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/technorati.png" title="Adicionar ao&nbsp;Technorati" alt="Adicionar ao&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2009%2F07%2Fjqdjangogrid-plugin-jquery-django-datagrid%2F" rel="nofollow" title="Adicionar ao&nbsp;Tip'd"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/tipd.png" title="Adicionar ao&nbsp;Tip'd" alt="Adicionar ao&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+jqDjangoGrid+%26%238211%3B+plugin+JQuery+com+Django+para+criar+datagrids+@+http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2009%2F07%2Fjqdjangogrid-plugin-jquery-django-datagrid%2F" rel="nofollow" title="Adicionar ao&nbsp;Twitter"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/twitter.png" title="Adicionar ao&nbsp;Twitter" alt="Adicionar ao&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http%3A%2F%2Fwww.gustavohenrique.net%2Fbrogui%2F2009%2F07%2Fjqdjangogrid-plugin-jquery-django-datagrid%2F&amp;t=jqDjangoGrid+%26%238211%3B+plugin+JQuery+com+Django+para+criar+datagrids" rel="nofollow" title="Adicionar ao&nbsp;Yahoo My Web"><img class="social_img" src="http://www.gustavohenrique.net/brogui/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Adicionar ao&nbsp;Yahoo My Web" alt="Adicionar ao&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.gustavohenrique.net/brogui/2009/07/jqdjangogrid-plugin-jquery-django-datagrid/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
