Comments (12)
Please take a look at issue #31
from laravel-jqgrid.
page not found :(
https://github.com/mgallegos/decima-erp/blob/master/workbench/mgallegos/decima-accounting/src/views/account-management.blade.php
from laravel-jqgrid.
Sorry, try:
https://github.com/mgallegos/decima-accounting/blob/master/src/views/account-management.blade.php
from laravel-jqgrid.
I tried for a long time, but not get the correct result (
if i creating my own implementation of repository class, something like this :
namespace App\Grids;
use Mgallegos\LaravelJqgrid\Repositories\RepositoryInterface;
class ExampleRepository implements RepositoryInterface {
public function getTotalNumberOfRows(array $filters = array())
{
return 5;
}
public function getRows($limit, $offset, $orderBy = null, $sord = null, array $filters = array(), $nodeId = null, $nodeLevel = null, $exporting = null )
{
return array(
array("id" => 1, "parent_id" => 0, "describe_tree" => "1", "payloads" => "some helpful information 1"),
array("id" => 2, "parent_id" => 0, "describe_tree" => "2", "payloads" => "some helpful information 2"),
array("id" => 3, "parent_id" => 1, "describe_tree" => "1-1", "payloads" => "some helpful information 3"),
array("id" => 4, "parent_id" => 2, "describe_tree" => "2-1", "payloads" => "some helpful information 4"),
array("id" => 5, "parent_id" => 2, "describe_tree" => "2-2", "payloads" => "some helpful information 5"),
);
}
/*
!!!!!!!!!!!!!!!!!!!!
it is necessary to describe here ?
treeGrid = true;
parentColumn = 'id';
eafColumn = 'parent_id';
how ?
????????????????????
*/
}
and creating view some like this:
/* is required to include some external Javascript ? */
GridRender::setGridId("test_tree")
->setGridOption('treeGrid', true)
->setGridOption('ExpandColumn', 'describe_tree')
->setGridOption('treeReader', array('parent_id_field' => 'id', 'leaf_field' => 'parent_id'))
->addColumn(array('index'=>'id', 'name' => 'id', 'hidden' => true ))
->addColumn(array('index'=>'parent_id', 'name' => 'parent_id', 'hidden' => true ) )
->addColumn(array('label'=>'describe_tree','index'=>'describe_tree', 'width' => 150 ) )
->addColumn(array('label'=>'payloads', 'index'=>'payloads', 'width' => 150 ) )
I expect to see something like this:
1 some helpful information 1
+1-1 some helpful information 3
2 some helpful information 2
+2-1 some helpful information 4
+2-2 some helpful information 5
but I get a flat table (((
1 some helpful information 1
2 some helpful information 2
1-1 some helpful information 3
2-1 some helpful information 4
2-2 some helpful information 5
where is error ?
from laravel-jqgrid.
ok, first the constructor of your repository class:
public function __construct()
{
$this->treeGrid = true;
$this->parentColumn = 'parent_id';
$this->leafColumn = 'is_leaf';
}
And in the getRows function add the leaf column (this is how the grid knows when you can extend the row, 0 to extend, 1 not to extend):
public function getRows($limit, $offset, $orderBy = null, $sord = null, array $filters = array(), $nodeId = null, $nodeLevel = null, $exporting = null )
{
return array(
array("id" => 1, "parent_id" => 0, "describe_tree" => "1", "payloads" => "some helpful information 1", "is_leaf" => 0),
array("id" => 2, "parent_id" => 0, "describe_tree" => "2", "payloads" => "some helpful information 2", "is_leaf" => 0),
array("id" => 3, "parent_id" => 1, "describe_tree" => "1-1", "payloads" => "some helpful information 3", "is_leaf" => 1),
array("id" => 4, "parent_id" => 2, "describe_tree" => "2-1", "payloads" => "some helpful information 4", "is_leaf" => 1),
array("id" => 5, "parent_id" => 2, "describe_tree" => "2-2", "payloads" => "some helpful information 5", "is_leaf" => 1),
);
}
Finally in the view, set the tree options correctly:
->setGridOption('treeGrid', true)
->setGridOption('ExpandColumn', 'describe_tree')
->setGridOption('treeReader', array('parent_id_field' => 'parent_id', 'leaf_field' => 'is_leaf'))
Let me know if it works!
from laravel-jqgrid.
And one more thing, try creating and example table in your database, because in this case your repository class will always be returning the same five rows instead of the childs of an specific parent.
from laravel-jqgrid.
not workin (
The result :
- I think that it is generally unnecessary :
public function __construct()
{
$this->treeGrid = true;
$this->parentColumn = 'parent_id';
$this->leafColumn = 'is_leaf';
}
because they generally are not declared in the RepositoryInterface. they are only used when json-answer preparing in EloquentRepositoryAbstract
- to display properly is really important only what jqGrid-library included on page, and what data is returned to the table from server.
can you show the correct json-response from server, in which is displayed correctly ?
from laravel-jqgrid.
The json looks good, are you sure you changed the treeReader property:
->setGridOption('treeReader', array('parent_id_field' => 'parent_id', 'leaf_field' => 'is_leaf'))
from laravel-jqgrid.
You are right, the field level is missing, this is automatically generated by the EloquentRepositoryAbstract class:
public function getRows($limit, $offset, $orderBy = null, $sord = null, array $filters = array(), $nodeId = null, $nodeLevel = null, $exporting = null )
{
return array(
array("id" => 1, "parent_id" => 0, "describe_tree" => "1", "payloads" => "some helpful information 1", "is_leaf" => 0, "level" => 0 ),
array("id" => 2, "parent_id" => 0, "describe_tree" => "2", "payloads" => "some helpful information 2", "is_leaf" => 0, "level" => 0 ),
}
from laravel-jqgrid.
I too found the missing "level"-field at this good example
my final correct data:
->setGridOption('treeGrid', true)
->setGridOption('ExpandColumn', 'describe_tree')
->setGridOption('treeReader', array('parent_id_field' => 'parent_id', 'leaf_field' => 'is_leaf'))
->addColumn(array('index'=>'id', 'name' => 'id', 'hidden' => true, 'key' => true ))
->addColumn(array('label'=>'describe_tree','index'=>'describe_tree', 'width' => 50 ) )
->addColumn(array('label'=>'payloads', 'index'=>'payloads', 'width' => 50 ) )
return array(
array("level" => 0, "id" => 1, "parent_id" => "", "describe_tree" => "1", "payloads" => "some helpful information 1", "is_leaf" => false),
array("level" => 1, "id" => 2, "parent_id" => "1", "describe_tree" => "1-1", "payloads" => "some helpful information 3", "is_leaf" => true),
array("level" => 0, "id" => 3, "parent_id" => "", "describe_tree" => "2", "payloads" => "some helpful information 2", "is_leaf" => false),
array("level" => 1, "id" => 4, "parent_id" => "3", "describe_tree" => "2-1", "payloads" => "some helpful information 4", "is_leaf" => true),
array("level" => 1, "id" => 5, "parent_id" => "3", "describe_tree" => "2-2", "payloads" => "some helpful information 5", "is_leaf" => true),
);
in my experience:
- leaf_field must be boolean (true or false), with 0/1 i got bug :
- if parent_id recived as string, then grid load as foled:
, else disclosed :
- row order is important, I expected that the jqGrid itself will sort them
Thank for help! Now all works fine.
Please, look at my pool requests ;)
from laravel-jqgrid.
Nice, I'm glad it worked!
P.D: Yes, I will take a look at them as soon as I can.
from laravel-jqgrid.
And when you do use the EloquentRepositoryAbstract, this code is necessary:
public function __construct()
{
$this->treeGrid = true;
$this->parentColumn = 'parent_id';
$this->leafColumn = 'is_leaf';
}
from laravel-jqgrid.
Related Issues (20)
- jqGridRender.php HOT 2
- How would you implement the selection box?
- ErrorException: getJavascriptExportFunctionCode() must be an instance of Mgallegos\LaravelJqgrid\Renders\string, string given HOT 1
- Format date columns when exporting
- Include footer row when exporting
- A non-numeric value encountered on php7
- Bug: failure to json encode data rows containing UTF8 chars. HOT 1
- Double click HOT 2
- Allowed memory size of 134217728 bytes exhausted HOT 1
- Bug: Undefined variable: modelDateFormatters
- Fix UTF8 issue with fetch data when exporting to XLS and CSV.
- Fix utf8 encoding issue
- UTF8 encoding isssue HOT 7
- Whoops, looks like something went wrong. HOT 3
- Bug when xls exporting
- skip adding <script> tag in render HOT 1
- Live Demos throwing 404 exception. HOT 1
- Problem when I use ->groupBy
- How can I handle Laravel raw query
- Compatibility with laravel 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-jqgrid.