Skip to content
This repository has been archived by the owner on Mar 10, 2021. It is now read-only.

Commit

Permalink
many improvements [juzna]
Browse files Browse the repository at this point in the history
  • Loading branch information
holubj committed Oct 13, 2012
1 parent 8060385 commit 73eb0bd
Show file tree
Hide file tree
Showing 54 changed files with 438 additions and 55 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# NiftyGrid

Simple and light-weight **datagrid** for *Nette framework*.


## Install
Add as *composer* dependancy to your `composer.json` file:

```
{
"require": {
"php" : ">=5.3.0",
"nette/nette" : "*",
"nifty/nifty-grid": "*"
}
}
```

Copy resources from `resources/` directory to your public www dir and include them in template (usually in `@layout.latte`).

## Usage

See manual on http://addons.nette.org/cs/niftygrid
30 changes: 30 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "nifty/nifty-grid",
"type": "nette-addon",
"description": "Simple & lightweight datagrid for nette",
"keywords": ["datagrid", "nette"],
"homepage": "http://addons.nette.org/cs/niftygrid",
"license": ["BSD-3"],
"authors": [
{
"name": "Jakub Holub"
}
],
"require": {
"php" : ">=5.3.2",
"nette/nette" : "*",
"nette/addon-installer": "@dev"
},
"autoload": {
"psr-0": { "NiftyGrid": "libs/" },
"classmap": [ "libs/NiftyGrid/GridExceptions.php" ]
},
"extra": {
"nette-addon": {
"assets": {
"css": [ "resources/css/" ],
"javascript": [ "resources/js/" ]
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
* @license New BSD Licence
* @link http://addons.nette.org/cs/niftygrid
*/
namespace NiftyGrid;
namespace NiftyGrid\Components;

use Nette;
use NiftyGrid;

class Action extends \Nette\Application\UI\PresenterComponent
{
Expand Down Expand Up @@ -92,7 +95,7 @@ public function setAjax($ajax)

/**
* @return mixed
* @throws UnknownActionCallbackException
* @throws NiftyGrid\UnknownActionCallbackException
*/
public function getAction()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @license New BSD Licence
* @link http://addons.nette.org/cs/niftygrid
*/
namespace NiftyGrid;
namespace NiftyGrid\Components;

use Nette\Utils\Html;
use NiftyGrid\Grid; // For constant only
Expand Down
31 changes: 18 additions & 13 deletions Components/Column.php → libs/NiftyGrid/Components/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
* @license New BSD Licence
* @link http://addons.nette.org/cs/niftygrid
*/
namespace NiftyGrid;
namespace NiftyGrid\Components;

use Nette;
use NiftyGrid,
NiftyGrid\Grid,
NiftyGrid\FilterCondition;


class Column extends \Nette\Application\UI\PresenterComponent
Expand Down Expand Up @@ -190,15 +195,15 @@ public function hasCellRenderer()
/**
* @param int $numOfResults
* @return Column
* @throws InvalidFilterException
* @throws UnknownFilterException
* @throws NiftyGrid\InvalidFilterException
* @throws NiftyGrid\UnknownFilterException
*/
public function setAutocomplete($numOfResults = 10)
{
if(empty($this->filterType)){
throw new UnknownFilterException("Autocomplete can't be used without filter.");
throw new NiftyGrid\UnknownFilterException("Autocomplete can't be used without filter.");
}elseif($this->filterType != FilterCondition::TEXT){
throw new InvalidFilterException("Autocomplete can be used only with Text filter.");
throw new NiftyGrid\InvalidFilterException("Autocomplete can be used only with Text filter.");
}
$this->parent['gridForm'][$this->parent->name]['filter'][$this->name]->getControlPrototype()
->addClass("grid-autocomplete")
Expand All @@ -225,13 +230,13 @@ public function getAutocompleteResults()
* @param bool $textarea
* @param null|int $cols
* @param null|int $rows
* @throws NiftyGrid\DuplicateEditableColumnException
* @return Column
* @throws DuplicateEditableColumnException
*/
public function setTextEditable($textarea = FALSE, $cols = NULL, $rows = NULL)
{
if($this->editable){
throw new DuplicateEditableColumnException("Column $this->name is already editable.");
throw new NiftyGrid\DuplicateEditableColumnException("Column $this->name is already editable.");
}

if($textarea){
Expand All @@ -251,12 +256,12 @@ public function setTextEditable($textarea = FALSE, $cols = NULL, $rows = NULL)
* @param array $values
* @param string|null $prompt
* @return Column
* @throws DuplicateEditableColumnException
* @throws NiftyGrid\DuplicateEditableColumnException
*/
public function setSelectEditable(array $values, $prompt = NULL)
{
if($this->editable){
throw new DuplicateEditableColumnException("Column $this->name is already editable.");
throw new NiftyGrid\DuplicateEditableColumnException("Column $this->name is already editable.");
}
$this->parent['gridForm'][$this->parent->name]['rowForm']->addSelect($this->name, NULL, $values)->getControlPrototype()->addClass("grid-editable");
if($prompt){
Expand All @@ -270,12 +275,12 @@ public function setSelectEditable(array $values, $prompt = NULL)

/**
* @return Column
* @throws DuplicateEditableColumnException
* @throws NiftyGrid\DuplicateEditableColumnException
*/
public function setBooleanEditable()
{
if($this->editable){
throw new DuplicateEditableColumnException("Column $this->name is already editable.");
throw new NiftyGrid\DuplicateEditableColumnException("Column $this->name is already editable.");
}
$this->parent['gridForm'][$this->parent->name]['rowForm']->addCheckbox($this->name, NULL)->getControlPrototype()->addClass("grid-editable");

Expand All @@ -286,12 +291,12 @@ public function setBooleanEditable()

/**
* @return Column
* @throws DuplicateEditableColumnException
* @throws NiftyGrid\DuplicateEditableColumnException
*/
public function setDateEditable()
{
if($this->editable){
throw new DuplicateEditableColumnException("Column $this->name is already editable.");
throw new NiftyGrid\DuplicateEditableColumnException("Column $this->name is already editable.");
}
$this->parent['gridForm'][$this->parent->name]['rowForm']->addText($this->name, NULL)->getControlPrototype()->addClass("grid-datepicker")->addClass("grid-editable");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @license New BSD Licence
* @link http://addons.nette.org/cs/niftygrid
*/
namespace NiftyGrid;
namespace NiftyGrid\Components;

use Nette\Utils\Html,
NiftyGrid\Grid; // For constant only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
* @license New BSD Licence
* @link http://addons.nette.org/cs/niftygrid
*/
namespace NiftyGrid;
namespace NiftyGrid\Components;

use Nette;
use NiftyGrid,
NiftyGrid\Grid;

class SubGrid extends \Nette\Application\UI\PresenterComponent
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @license New BSD Licence
* @link http://addons.nette.org/cs/niftygrid
*/
namespace NiftyGrid;
namespace NiftyGrid\DataSource;

use NiftyGrid\FilterCondition,
Nette\Utils\Strings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @license New BSD Licence
* @link http://addons.nette.org/cs/niftygrid
*/
namespace NiftyGrid;
namespace NiftyGrid\DataSource;

interface IDataSource
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,42 @@
* @license New BSD Licence
* @link http://addons.nette.org/cs/niftygrid
*/
namespace NiftyGrid;
namespace NiftyGrid\DataSource;

use NiftyGrid\FilterCondition;

class NDataSource implements IDataSource
{
private $data;
private $table;

public function __construct($data)
public function __construct($table)
{
$this->data = $data;
$this->table = $table;
}

public function getData()
{
return $this->data;
return $this->table;
}

public function getPrimaryKey()
{
return $this->data->getPrimary();
return $this->table->getPrimary();
}

public function getCount($column = "*")
{
return $this->data->count($column);
return $this->table->count($column);
}

public function orderData($by, $way)
{
$this->data->order($by." ".$way);
$this->table->order($by." ".$way);
}

public function limitData($limit, $offset)
{
$this->data->limit($limit, $offset);
$this->table->limit($limit, $offset);
}

public function filterData(array $filters)
Expand All @@ -58,7 +58,7 @@ public function filterData(array $filters)
if(!empty($filter["valueFunction"])){
$column .= $filter["valueFunction"]."(?)";
}
$this->data->where($column, $value);
$this->table->where($column, $value);
}
}
}
Expand Down
File renamed without changes.
Loading

0 comments on commit 73eb0bd

Please sign in to comment.