Skip to content
This repository was archived by the owner on Mar 10, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
33 changes: 33 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"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",
"nette/extras": "@dev"
},
"autoload": {
"psr-0": { "NiftyGrid": "libs/" },
"classmap": [ "libs/NiftyGrid/GridExceptions.php" ]
},
"extra": {
"nette-addon": {
"assets": {
"images": [ "resources/css/images/" ],
"css": [ "resources/css/grid.css" ],
"javascript": [ "resources/js/grid.js" ]
},
"extras": [ "jQuery", "jQuery-UI", "netteForms" ]
}
}
}
Binary file removed css/jquery-ui/images/ui-bg_flat_0_aaaaaa_40x100.png
Binary file not shown.
Binary file removed css/jquery-ui/images/ui-bg_glass_95_fef1ec_1x400.png
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed css/jquery-ui/images/ui-icons_666666_256x240.png
Binary file not shown.
Binary file removed css/jquery-ui/images/ui-icons_aaaaaa_256x240.png
Binary file not shown.
Binary file removed css/jquery-ui/images/ui-icons_bbbbbb_256x240.png
Binary file not shown.
Binary file removed css/jquery-ui/images/ui-icons_c98000_256x240.png
Binary file not shown.
Binary file removed css/jquery-ui/images/ui-icons_cccccc_256x240.png
Binary file not shown.
Binary file removed css/jquery-ui/images/ui-icons_cd0a0a_256x240.png
Binary file not shown.
Binary file removed css/jquery-ui/images/ui-icons_f29a00_256x240.png
Binary file not shown.
354 changes: 0 additions & 354 deletions css/jquery-ui/jquery-ui.css

This file was deleted.

21 changes: 0 additions & 21 deletions js/jquery-ui.js

This file was deleted.

12 changes: 8 additions & 4 deletions Components/Action.php → libs/NiftyGrid/Components/Action.php
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 NiftyGrid;
use Nette;

class Action extends \Nette\Application\UI\PresenterComponent
{
Expand Down Expand Up @@ -77,14 +81,14 @@ public function getCallback()

/**
* @return mixed
* @throws UnknownActionCallbackException
* @throws NiftyGrid\UnknownActionCallbackException
*/
public function getAction()
{
if(empty($this->callback)){
throw new UnknownActionCallbackException("Action $this->name doesn't have callback.");
throw new NiftyGrid\UnknownActionCallbackException("Action $this->name doesn't have callback.");
}
$option = \Nette\Utils\Html::el('option')->setValue($this->name)->setText($this->label);
$option = Nette\Utils\Html::el('option')->setValue($this->name)->setText($this->label);
if(!empty($this->dialog)){
$option->addData("grid-confirm", $this->dialog);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
* @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
32 changes: 19 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,13 @@
* @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 @@ -179,15 +185,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 @@ -212,12 +218,12 @@ public function getAutocompleteResults()

/**
* @return Column
* @throws DuplicateEditableColumnException
* @throws NiftyGrid\DuplicateEditableColumnException
*/
public function setTextEditable()
{
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-editable");
Expand All @@ -231,12 +237,12 @@ public function setTextEditable()
* @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 @@ -250,12 +256,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 @@ -266,12 +272,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,12 @@
* @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 Expand Up @@ -111,7 +116,7 @@ public function getLink($row)

/**
* @param callback|string $cellStyle
* @return \Nifty\Grid\SubGrid
* @return SubGrid
*/
public function setCellStyle($cellStyle)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
* @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,8 @@
* @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,43 +7,46 @@
* @license New BSD Licence
* @link http://addons.nette.org/cs/niftygrid
*/
namespace NiftyGrid;

namespace NiftyGrid\DataSource;

use NiftyGrid\FilterCondition,
Nette\Utils\Strings;
Nette\Utils\Strings,
Nette\Database\Table\Selection;

class NDataSource implements IDataSource
{
private $data;
/** @var Selection */
private $table;

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

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

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

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

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 @@ -59,7 +62,7 @@ public function filterData(array $filters)
if(!empty($filter["valueFunction"])){
$column .= $filter["valueFunction"]."(?)";
}
$this->data->where($column, $value);
$this->table->where($column, $value);
}elseif($filter["type"] == FilterCondition::HAVING){
$having[$filter["column"]] = $filter;
}
Expand All @@ -78,7 +81,7 @@ public function filterData(array $filters)
$stringHaving .= " AND ";
}
}
$this->data->group("id", $stringHaving);
$this->table->group("id", $stringHaving);
}
}
}
File renamed without changes.
Loading