<?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>GustavoHenrique.net &#187; datagrid</title>
	<atom:link href="http://blog.gustavohenrique.net/tag/datagrid/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.gustavohenrique.net</link>
	<description>Tecnologia e Software Livre</description>
	<lastBuildDate>Mon, 05 Mar 2012 10:50:09 +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>jqDjangoGrid &#8211; plugin JQuery com Django para criar datagrids</title>
		<link>http://blog.gustavohenrique.net/2009/07/jqdjangogrid-plugin-jquery-django-datagrid/</link>
		<comments>http://blog.gustavohenrique.net/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 [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_119" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.gustavohenrique.net/wp-content/uploads/2009/07/jqdjangogrid1.jpg"><img src="http://blog.gustavohenrique.net/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>
]]></content:encoded>
			<wfw:commentRss>http://blog.gustavohenrique.net/2009/07/jqdjangogrid-plugin-jquery-django-datagrid/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

